<分区>
<分区>
我有这个 html;
<div class="1"><br/>hi</div>
<div class="2"><br/>hi</div>
<div class="3"><br/>hi</div>
<div class="4"><br/>hi</div>
然后我向 div 添加了正常的 CSS 格式;
div{
height: 100px;
width: 100px;
border-radius: 100%;
margin: 20px;
display: inline-block;
text-align: center;
}
然后我希望每个 div 都有不同的颜色,所以我使用了这样的类;
.1{
background-color: pink;
}
.2{
background-color: red;
}
.3{
background-color: orange;
}
.4{
background-color: yellow;
}
我在 Dreamweaver 中写这篇文章,当我点击 div 时,小类的东西告诉我它们是彩色的,代码正在工作,但是当我在浏览器中预览时,颜色没有显示出来,我只是得到了CSS 的 div 部分。 这可能非常明显,但我想不出为什么会这样。 谢谢:)
最佳答案
请避免使用以数字开头的类。它肯定会失败。 您可以使用例如 cl1、cl2、cl3 等。
关于html - 为什么 CSS 类不能在浏览器中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26319987/