What I want to achieve is for all the elements to be on the same line, but have the text-overflow kick in if the paragraph in the middle is wider than the available space, but if not, then the right float should still be in the same line.

我想要实现的是所有元素都在同一行,但是如果中间的段落比可用空间宽,则会有文本溢出,但如果没有,那么右浮点应该仍然在同一条线。

Codepen: http://codepen.io/anon/pen/hHvCA

HTML:

<div id="outer">
  <div id="left"></div>
  <div id="middle">
    <p>Can this paragraph fill the space between the left and right floats without making the right float wrap?</p>
  </div>
  <div id="right"></div>
</div>

CSS:

#outer {
  background-color: #222;
  height: 100px;
  width: 100%;
}

#left {
  background-color: #555;
  width: 100px;
  height: 100px;
  float: left;
}

#right {
  background-color: #777;
  width: 200px;
  height: 100px;
  float: right;
}

#middle {
   background-color: #999;
   height: 100px;
}

#middle > p {
   line-height: 100px;
   color: #eee;
   text-overflow: ellipsis;
   white-space: nowrap;
   overflow: hidden;
   font-family: monospace;
}

6 个解决方案

#1


2

Use a

float: left

on the #middle one. Also, try setting a width, to avoid the middle div spanning to 100%

在#middle上。另外,尝试设置宽度,以避免中间div跨越100%

更多相关文章

  1. 当内容宽度为自动时,隐藏滚动条(仍然能够滚动)不起作用
  2. 两个并列的div,一个确定宽度一个自动调整
  3. 如何让我的固定宽度移动网站始终显示“完全放大”?
  4. CSS3列 - 添加第二个元素后的额外宽度
  5. 如何使用“left:100%”CSS规则保留DIV宽度
  6. 使三个标签填充容器的宽度
  7. PHP选择具有特定宽度的图像并构建网格
  8. 具有固定宽度网格的引导程序和应跨越窗口宽度的图像
  9. Div高度为图像高度,图像宽度为div宽度

随机推荐

  1. TCP在Linux内核中调用流
  2. linux notepadqq不支持中文输入的原因分
  3. Linux下的find 命令使用实例
  4. UBUNTU 12.04下傻瓜式简单安装arm-linux-
  5. 在Ubuntu 9.10中有奇怪的pynotify行为
  6. Linux系统安装并使用Tomcat
  7. 通过指令“ps -l”查看进程信息
  8. 用虚拟机装的linux与宿主机的IP能互ping
  9. 计算所有字符,包括linux中的空格
  10. Linux服务列表(CentOS)