css - 无法识别 CSS 中的某些部分

标签 css

为什么有时无法识别 CSS 中的某些部分,有时却可以?我的代码如下:

<section class="generalContainer"><time>8 September 2016</time></section>
<section class="oath-takingContainer"><time>12 October 2016</time></section>

section.generalContainer {
    position: absolute;
    width: 100%;
    text-align: center;
    margin: -15px 0 10px -15px;
    padding: 5px 0 5px 0;
    background: #868A08;
    }

section.oath-takingContainer {
position: absolute;
width: 100%;
text-align: center;
margin: -15px 0 10px -15px;
padding: 5px 0 5px 0;
background: #08088A;
}

网站只承认section.generalContainer,不承认oath-takingContainer。我使用了 Chrome 检查功能,请查看 CSS 的右侧框。 generalContainer 和 oath-takingContainer 的区别。前者被识别,后者不被识别。

enter image description here

enter image description here

enter image description here

最佳答案

因为您无法检查 section.oath-takingContainer,因为它被 CSS 直接放置在另一个 div 下方...您实际上无法右键单击并“检查”它。

为了清晰起见,我在这里应用了更亮的颜色,并将下方的 div 从上方的 div 移开,现在可以正常检查了。

section.generalContainer {
  position: absolute;
  width: 100%;
  text-align: center;
  margin: -15px 0 10px -15px;
  padding: 5px 0 5px 0;
  background: red;
}

section.oath-takingContainer {
  position: absolute;
  width: 100%;
  text-align: center;
  margin: -15px 0 10px -15px;
  padding: 5px 0 5px 0;
  background: pink;
  top: 50px;
}
<section class="generalContainer"><time>8 September 2016</time></section>
<section class="oath-takingContainer"><time>12 October 2016</time></section>

关于css - 无法识别 CSS 中的某些部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42885860/

相关文章:

javascript - 如何使用JS改变网页上所有文字的颜色?

jQuery removeClass 函数不起作用

javascript - CSS3 动画与点击冲突

jquery - 将 Twitter 小部件宽度扩展到 520px 限制之外 : post-March 2016

css - 当屏幕变窄时,我如何解释 Bootstrap 4 固定导航栏变高

javascript - jquery - 旋转一次

jquery - 让背景图片滚动到我的其他 <div> 列后面

html - xHtml 下载文件到硬盘

javascript - 滚动弹出问题

html - 在 html 中存在表单使得在 chrome 中加载时发生 css 转换