I have this html code
我有这个html代码
<ul>
<div id="consolidation-checkboxes-container" class="consolidation-checkboxes container" style="height: 104px;">
<a href="" class="consolidation-link" target="_blank">
<li>one</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>two</li>
</a>
<a href="" class="consolidation-link bordered" target="_blank">
<li>three</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>four</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>five</li></a>
<a href="" class="consolidation-link" target="_blank">
<li>six</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>seven</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>eight</li>
</a>
</div>
</ul>
I would like the seventh li not have bullet.Is this possible to be done with css, because I am not allowed to change the html
我希望七里没有子弹。这是否可以用css完成,因为我不允许更改html ?
2 个解决方案
#1
-2
you can also do like this to exactly catch the nth-child..
你也可以这样做来抓住第一个孩子。
ul > div > a:nth-child(7) > li {
list-style-type: none;
}
#2
10
If your html is the one you provide you can use the following code:
如果您的html是您提供的,您可以使用以下代码:
ul div a:nth-child(7) li {
list-style-type: none;
}
<ul>
<div id="consolidation-checkboxes-container" class="consolidation-checkboxes container" style="height: 104px;">
<a href="" class="consolidation-link" target="_blank">
<li>one</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>two</li>
</a>
<a href="" class="consolidation-link bordered" target="_blank">
<li>three</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>four</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>five</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>six</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>seven</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>eight</li>
</a>
</div>
</ul>
Additional as mention in comments ul
element can only contain zero or more li
elements, eventually mixed with ol
and ul
elements. So you can change your html mark up to be valid like:
注释中提到的附加元素ul只能包含零个或多个li元素,最终与ol和ul元素混合。所以你可以把html标记改为:
ul li:nth-child(7) {
list-style-type: none;
}
<ul>
<li><a href="#" class="consolidation-link" target="_blank">one</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">two</a>
</li>
<li><a href="#" class="consolidation-link bordered" target="_blank">three</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">four</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">five</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">six</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">seven</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">eight</a>
</li>
</ul>
#1
-2
you can also do like this to exactly catch the nth-child..
你也可以这样做来抓住第一个孩子。
ul > div > a:nth-child(7) > li {
list-style-type: none;
}
#2
10
If your html is the one you provide you can use the following code:
如果您的html是您提供的,您可以使用以下代码:
ul div a:nth-child(7) li {
list-style-type: none;
}
<ul>
<div id="consolidation-checkboxes-container" class="consolidation-checkboxes container" style="height: 104px;">
<a href="" class="consolidation-link" target="_blank">
<li>one</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>two</li>
</a>
<a href="" class="consolidation-link bordered" target="_blank">
<li>three</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>four</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>five</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>six</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>seven</li>
</a>
<a href="" class="consolidation-link" target="_blank">
<li>eight</li>
</a>
</div>
</ul>
Additional as mention in comments ul
element can only contain zero or more li
elements, eventually mixed with ol
and ul
elements. So you can change your html mark up to be valid like:
注释中提到的附加元素ul只能包含零个或多个li元素,最终与ol和ul元素混合。所以你可以把html标记改为:
ul li:nth-child(7) {
list-style-type: none;
}
<ul>
<li><a href="#" class="consolidation-link" target="_blank">one</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">two</a>
</li>
<li><a href="#" class="consolidation-link bordered" target="_blank">three</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">four</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">five</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">six</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">seven</a>
</li>
<li><a href="#" class="consolidation-link" target="_blank">eight</a>
</li>
</ul>