html - css 背景属性在 chrome 和 firefox 中不起作用

标签 html css background-color

<分区>


这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助 future 的读者。

关闭 4 年前

我的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*/

关于html - css 背景属性在 chrome 和 firefox 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54977572/

上一篇:css - 如何在顶部放置 Shiny 的内联单选按钮文本

下一篇:CSS 显示 : -webkit-box not working in Internet Explorer 11

相关文章:

android - 触摸更改 TextView 背景颜色

iphone - UITableViewCell 突出显示时使标签的背景清晰

html - 主题在第一次加载时无法正确显示图像

css - Angular 10 : Router with anchorScrolling does not work on div with position absolute and overflow: auto

javascript - Div的自动CSS高度

HTML/CSS 如何使用自定义数据属性将 CSS 应用于 "a"?

html - position=fixed div 内 div 的 margin-right

delphi - 如何启用应用程序范围的配色方案?

html - 如何使用 c 访问网页来维护 Atheros 板上的 session

javascript - jQuery - bpopup 插件,我需要重现方面的帮助