这是标记:
<nav id="the-nav">
<span id="backward"><i class="icon-backward"></i></span>
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="active-module"></span>
</a>
<ul class="dropdown-menu">
<li>
<a href="#"><img src="..."></a>
</li>
<li>
<a href="#"><img src="..."></a>
</li>
</ul>
</div>
<div class="wrapper">
<div class="modules">
<div class="module active">
<a href="..."><i class="icon-*"></i></a> <!-- a few bootstrap icons are used -->
<a href="..."><i class="icon-*"></i></a>
<a href="..."><i class="icon-*"></i></a>
</div>
<div class="module">
<a href="..."><i class="icon-*"></i></a>
<a href="..."><i class="icon-*"></i></a>
<a href="..."><i class="icon-*"></i></a>
<!-- More items here... -->
</div>
<!-- More modules here... -->
</div>
</div>
<span id="forward"><i class="icon-forward"></i></span>
</nav>
这是less/css:
#the-nav {
@itemDimension: 35px;
@dropdownWidth: 150px;
background: white;
bottom: 0;
left: 0;
position: fixed;
width: 100%;
/* Square mixin for items and navigator arrows. */
.square () {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
height: @itemDimension;
padding: 3px;
width: @itemDimension;
}
div, span { float: left; }
/* Module Dropdown */
.dropdown {
font-size: 12px;
white-space: nowrap;
width: @dropdownWidth;
/* Make dropdown drop "up". */
&.open > .dropdown-menu {
bottom: 100%;
top: inherit;
}
.active-module {
overflow: hidden;
text-overflow: ellipsis;
width: @dropdownWidth;
}
img {
height: 30px;
width: 30px;
}
}
.wrapper {
overflow: hidden;
position: relative;
white-space: nowrap;
/* Set width so that there is just enough room for the forward and back
* arrows. As a fallback, give it a percentage width. */
width: 88%;
width: -webkit-calc(100% ~'-' 2*@itemDimension+@dropdownWidth);
width: -moz-calc(100% ~'-' 2*@itemDimension+@dropdownWidth);
width: calc(100% ~'-' 2*@itemDimension+@dropdownWidth);
}
/* Forward/backward scoll buttons */
#forward, #backward {
.square;
padding: 7px 0 0 10px;
&:hover {
background: lightblue;
}
}
/* Module items */
.module > a {
.square;
float: left;
text-align: center;
i {
display: block !important;
font-size: 120%;
margin-top: 6px !important;
}
}
.module:not(.active) { display: none; }
}
显示的模块(由下拉菜单决定)是使用 javascript 设置的。
我希望整个导航栏保持在一条线上。目前,它适用于 Chrome,但不适用于 Firefox。在 Firefox 中,每个模块的内容都会换行,这样整个导航栏就会跨越多行。我希望这一切都保持在一条线上。
我有一种感觉 , , 的组合,display
这会得到我想要的,但我不确定那个组合是什么。float
white-space
更新 这是一个代码笔,它准确地显示了我想要的东西。同样,这适用于 chrome,但不适用于 Firefox。http://codepen.io/anon/pen/Bolnd