html – 创建Bootstrap 3 Navbar而不包装文本的最佳方法(并且没有折叠)

我正在尝试使用Bootstrap 3创建一个不会折叠或包装文本的Navbar.我希望文本只是被剪切(或省略)而不是包装 – 因此Navbar保持在一条线上而不会垂直扩展. (此Navbar将用于显示具有单个右对齐菜单的当前视图位置)

像这样的东西:

<div class="navbar navbar-fixed-top navbar-inverse">

    <div class="navbar-header pull-left">
        <p class="navbar-text" style="overflow: hidden; white-space: Nowrap;">
            Trying to get this long line of text to not wrap even if too wide for the view to display. Trying to get this long line of text to not wrap even if too wide for the view to display.
        </p>
    </div>

    <div class="navbar-header pull-right">
        <p class="navbar-text">Menu</p>
    </div>

</div>

如图所示,我一直在愚弄CSS浮动,溢出,空白设置,似乎无法得到正确的组合.此外,我使用两个navbar-header元素来避免崩溃,但如果有更好的方法,我会对其他选项持开放态度.

谢谢您的帮助.

解决方法

http://jsbin.com/elezawA/1/

这是一个很好的固定版本:http://jsbin.com/elezawA/2

body {
 padding-top: 50px;
}

.overflow {
  position:absolute;
  top:0;
  left:0;
  display: block;
  text-overflow: ellipsis;
  white-space: Nowrap;
  overflow: hidden;
  margin-top: 0;
  color:#ccc;
  max-width:90%;
}

  .overflow p {color:#ccc;line-height:50px;padding:0 10px;margin:0;display:inline;}


 <div class="navbar navbar-fixed-top navbar-inverse">

    <div class="navbar-header">
      <span class="overflow">
       <p>
        Trying to get this long line of text to not wrap even if too wide for the view to display. Trying to get this long line of text to not wrap even if too wide for the view to display.
         </p> 
     </span>
   </div>

   <div class="navbar-header pull-right">
       <p class="navbar-text">Menu</p>
    </div>

 </div>

必须在较小的宽度上摆弄百分比以允许菜单区域.在这个上做一个最小宽度,你会弄明白的.也许添加一些填充,以使其不掩盖.我将在今天或明天稍后看到这个问题.

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些