css 后台 属性 在 chrome 和 firefox 中不工作
css background property not working in chrome and 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>
谁能告诉我问题出在哪里?
删除评论,这是导致错误的原因
css 代码中的注释应该像这样 /*your comment*/
您不能在 CSS 中使用双正斜杠 (//) 进行评论。
<html>
<head>
<style>
.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;
}
</style>
</head>
<body>
<div class="box-orange"></div>
<div class="box-red"></div>
</body>
</html>
评论导致您出错。尝试通读以下 link.
我的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>
谁能告诉我问题出在哪里?
删除评论,这是导致错误的原因
css 代码中的注释应该像这样 /*your comment*/
您不能在 CSS 中使用双正斜杠 (//) 进行评论。
<html>
<head>
<style>
.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;
}
</style>
</head>
<body>
<div class="box-orange"></div>
<div class="box-red"></div>
</body>
</html>
评论导致您出错。尝试通读以下 link.