我无法理解如何应用 CSS 规则。
对于 div 中的段落,我想应用这个新定义的规则:
.imgDescription {
position: absolute;
right: 10px;
color: #000;
}
但该段落的样式仍按前面的规则设置:
.dark-wrapper .inner p {
font-family: 'Open Sans';
font-size:14px;
color:#CCC;
}
我不知道如何解决这个问题。
最佳答案
您可以将 !important
添加到您的样式中。
.imgDescription {
position: absolute !important;
right: 10px !important;
color: #000 !important;
}
或者在.dark-wrapper .inner p
部分定义.imgDescription
。据我所知,CSS 定义是根据它们在定义中的顺序来加权的。纠正我,如果我在这里错了......
关于html - 无法应用新定义的 CSS 规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18531339/