【发布时间】:2015-11-15 03:13:50
【问题描述】:
我可能理解错了,但是;我正在使用<ol> 和<li> 制作图表。出于某种原因,我应用于<ol> 标签的 CSS 也被应用于<li> 标签,但不是全部,一些<li> CSS 属性也被应用,有点像它的收入属性从他们两个。有人可以解释一下原因和解决方法吗?
https://jsfiddle.net/fdo47tjv/
div.alb1 {
background-color: rgba(255, 255, 255, 0.6);
width: 20%;
margin-left: 5%;
margin-top: 15%;
margin-bottom: 0px;
margin-right: 0px;
border-right: 40px solid black;
}
div.alb1 ol {
text-decoration: underline;
font-weight: bold;
font-size: 25px;
font-family: 'Roboto', sans-serif;
margin: 10px;
}
div.alb1 ol li {
margin: 5px;
text-decoration: none;
font-family: 'Roboto', sans-serif;
font-size: 15px;
}
<body background="./resources/DSC_0146.jpg">
<div class="alb1">
<ol>Take Care
<li>Over My Dead Body</li>
</ol>
</div>
</body>
经过一番折腾 我搞砸了并更改了 css 和 html,以便将“小心”移动到 OL 之外的段落标记,我对其进行了更改,因此段落标记将具有上面引用的 OL 属性,并且它工作正常但是这个好像不满意,是不是抄近路了?
【问题讨论】:
-
如果你的意思是
text-decoration,那么它不是继承属性,所以你不能为后代“取消”它。 -
检查这个问题:stackoverflow.com/questions/1823341/… 导致w3.org/TR/CSS21/text.html#propdef-text-decoration
The 'text-decoration' property on descendant elements cannot have any effect on the decoration of the ancestor. -
像这样将文本节点放在
<ol>标记内是无效的。您应该将您的标题放在列表之外或具有自己的样式属性的特殊<li>元素内。