搜索
您的当前位置:首页正文

同级类名写样式不加空格 可以起作用

来源:二三娱乐

1️⃣ ul li.bb.bb2{
}
2️⃣ ul li .bb .bb2{
}
观察1️⃣ 2️⃣有什么不同

image.png
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试类名</title>
    <style type="text/css" media="screen">
        .aa{
            background-color: red;
        }
        ul li.bb{
            background-color: blue;
        }
        ul li.bb.bb2{
            background-color: pink;
        }
        ul li.bb2.bb3{
            background-color: yellow;
        }
    </style>
</head>
<body>
    <div>
        <ul>
            <li class="aa">1</li>
            <li class="bb bb2 bb3">2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ul>
    </div>
</body>
</html>
Top