[英]3 level ul li ul li liststyle css problem
i'am not going into this i've an unordered list but i don't get the style working. 我不打算讨论这个问题,但我没有排序的顺序,但是我没有使样式起作用。 hope you can help me!
希望你能帮我!
My html code: 我的html代码:
<ul id="sitemap-list">
<li><a href="#" onclick="">LEV0</a>
<ul>
<li><a href="#" onclick="">LEV11</a></li>
<li><a href="#" onclick="">LEV1</a></li>
</ul>
</li>
<li><a href="#" onclick="">LEV0</a>
<ul>
<li><a href="#" onclick="">LEV1</a>
<ul>
<li><a href="#" onclick="">LEV2</a></li>
<li><a href="#" onclick="">LEV2</a></li>
</ul>
</li>
</ul>
</li>
</ul>
And my CSS Code: 还有我的CSS代码:
#sitemap-list li ul li a {
display: block;
text-decoration: none;
list-style-type: none;
color: red;
margin-left: 20px;
margin-top: -5px;
}
#sitemap-list ul li ul li a {
display: block;
text-decoration: none;
list-style-type: none;
color: #6e90a6;
margin-left: 50px;
}
The problem is that the first css "block" styles all list items with an a-tag. 问题在于,第一个css“块”使用a标签标记所有列表项的样式。
What do I do wrong? 我做错了什么?
thank you for your help :) 谢谢您的帮助 :)
The selector AB
is the descendent selector and matches any B
element that is a descendant of an A
element , no matter if it's a direct descentent (child node of an A
element) or if it's just a transitive descentend (eg child node of a child node of an A
element). 选择器
AB
是后代选择器,并且匹配作为A
元素后代的任何B
元素,无论它是直接后代( A
元素的子节点)还是只是可传递后代(例如子节点) A
元素的节点)。
If you want to select just the immediate child nodes, use the child selector A > B
: 如果只想选择直接子节点,请使用子选择器
A > B
:
#sitemap-list > li > ul > li > a { /* … */ }
#sitemap-list > li > ul > li > ul > li > a { /* … */ }
But since the Internet Explorer doesn't support the child selector, you will need to “reset” the properties that have been overwritten, eg the margin-top
property: 但是,由于Internet Explorer不支持子选择器,因此您需要“重置”已被覆盖的属性,例如
margin-top
属性:
#sitemap-list ul li ul li a {
margin-top: 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.