Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

css练习

作者:﹏尐甶园   发布日期:2025-08-13   浏览:72

/* CSS 练习示例代码 */

/* 1. 基本选择器 */
body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
}

h1 {
    color: #333;
}

p {
    color: #666;
}

/* 2. 类选择器 */
.red-text {
    color: red;
}

.blue-background {
    background-color: blue;
    color: white;
}

/* 3. ID 选择器 */
#main-header {
    text-align: center;
    padding: 20px;
}

/* 4. 组合选择器 */
ul li {
    list-style-type: square;
}

/* 5. 伪类选择器 */
a:hover {
    text-decoration: none;
    color: orange;
}

/* 6. 盒模型 */
.box {
    width: 200px;
    height: 100px;
    padding: 10px;
    border: 2px solid black;
    margin: 20px;
}

/* 7. 定位 */
.fixed-box {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background-color: yellow;
    padding: 5px;
}

/* 8. 响应式设计 */
@media (max-width: 600px) {
    body {
        background-color: lightblue;
    }

    h1 {
        font-size: 24px;
    }
}

解释说明:

  1. 基本选择器:对 bodyh1p 元素应用样式,设置字体、背景颜色和文本颜色。
  2. 类选择器:通过 .red-text.blue-background 类来设置特定元素的颜色和背景颜色。
  3. ID 选择器:使用 #main-header 来选择具有特定 ID 的元素,并设置居中对齐和内边距。
  4. 组合选择器:对嵌套在 ul 中的 li 元素设置列表项样式。
  5. 伪类选择器:当鼠标悬停在链接上时,移除下划线并改变颜色。
  6. 盒模型:定义一个具有宽度、高度、内边距、边框和外边距的盒子。
  7. 定位:将一个元素固定在页面底部右角。
  8. 响应式设计:根据屏幕宽度调整样式,在宽度小于 600px 时改变背景颜色和标题字体大小。

上一篇:css 背景颜色透明度

下一篇:动画css

大家都在看

css 红色

css 瀑布流布局grid

css文字超长省略号

css 渐变字体

css背景图片等比例缩放

css文字删除线

animation css3

css 自定义滚动条

css flex gap

css上一个兄弟元素怎么找到

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站