首页 > 解决方案 > CSS背景属性在chrome和firefox中不起作用

问题描述

我的html代码如下。我用 Chrome 和 Firefox 测试了它。在这两种浏览器中,第一个 div 的背景颜色都不起作用。

.box-orange {
  // without any position declaration    
  background: orange;
  height: 100px;
  width: 100px;
  border: 1px solid blue;
}

.box-red {
  background: green;
  height: 100px;
  width: 100px;
  border: 1px solid red;
}
<html>

<head>
</head>

<body>
  <div class="box-orange"></div>
  <div class="box-red"></div>
</body>

</html>

谁能告诉我问题出在哪里?

标签: htmlcssbackground-color

解决方案


删除注释,导致css代码中错误注释的原因应该是这样的/*your comment*/


推荐阅读