[英]css display:inline does not work on <li> element
I have this HTML: 我有这个HTML:
<div class="nav">
<ul class="nav-dots">
<li class='ni n1'><a href="" class='nia'>dot</a></li>
<li class='ni n2'><a href="" class='nia'>dot</a></li>
<li class='ni n3'><a href="" class='nia'>dot</a></li>
</ul>
</div>
With this CSS: 使用此CSS:
.nav-dots {
display: inline-block;
}
As you can see, the <li>
elements should display inline, but, they don't, and I have no idea why. 如您所见,
<li>
元素应该以内联方式显示,但是它们没有显示,我也不知道为什么。 How can I fix this? 我怎样才能解决这个问题?
It should be 它应该是
.nav-dots li {
display: inline-block;
}
or 要么
.ni {
display: inline-block;
}
Your CSS is applying the inline-block display property to the ul, not the li children 您的CSS正在将内联块显示属性应用于ul,而不是li子级
also 也
.ni{display:inline}
will work 将工作
display
is not a property that is inherited. display
不是继承的属性。 In order to keep the same structure you have and make the list items inline, you have to explicitly set their display property to inherit
: 为了保持相同的结构并使列表项内联,必须显式设置其display属性以
inherit
:
li { list-style-type:none; display:inherit; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.