[英]Why can I not force ul to behave as a table-row?
I am using bootstrap3
, and I would like to have a navbar
, where all nav
items are spaced through the whole width of the bar. 我正在使用
bootstrap3
,并且我想有一个navbar
,其中所有nav
项都在条的整个宽度上隔开。
To achieve this my only option was to make the bar behave like a table
, -row
, respectively -cell
. 要实现此目的,我唯一的选择是使栏的行为类似于
table
-row
或-cell
。
I've got the right markup & css, but apparently somehow I cannot force display: table-row;
我有正确的标记和CSS,但是显然我不能以某种方式强制
display: table-row;
on my ul
. 在我的
ul
。
Odd thing is that: 奇怪的是:
Both firefox & chromium report that although table-row
is the most important rule, they apply block
Firefox和Chrome都报告虽然
table-row
是最重要的规则,但它们适用于block
bootstrap3
(try toggling it in the live example) bootstrap3
时发生(尝试在实际示例中进行切换) <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="">
<a href="#">Homeen</a>
</li>
<li class="">
<a href="#">News</a>
</li>
</ul>
</div>
.collapse.navbar-collapse {
display: table !important;
width: 100%;
}
.navbar .nav {
display: table-row !important;
width: 100%;
background: #fff;
}
.navbar .nav > li {
display: table-cell !important;
background: #39f;
float: none;
}
Just make it a table man. 只是让它成为餐桌男人。
All the crazy code you're going to have to write to make this work without any browser bugs is going to be far more ugly than a table tag. 要使此工作正常进行而没有任何浏览器错误,您将必须编写所有疯狂的代码,而这些错误的代码将比表标记更丑陋。
I've figured it out 我知道了
I just had to unfloat .nav
我只需要取消浮动
.nav
.nav {
float: none;
}
Sigh , another lost hour. 叹气 ,又是一个小时的迷失 But I will leave the question up, maybe it saves someone's time.
但是我将问题抛在脑后,也许可以节省一个人的时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.