css - 如何摆脱 Chrome 和 Safari 中的水平滚动条?

标签 css twitter-bootstrap

如何去掉这段代码中的水平滚动条:codepen ?我在 Safari 和 Chrome 中看到它,但在 Firefox 中看不到。

我正在使用 bootstrap,我得到了大致如下的标记:

<div class="container">
  <div class="row">
    <div class="messages span6 offset1">
      <table class="table">
        <tbody>
          <tr>
            <td class=timestamp>[2:22 PM]</td>
            <td>echo|</td>
            <td>zot: Got a paste or gist of the code?</td>
          </tr>
          <!-- many more rows… -->
        </tbody>
      </table>
    </div>
  </div>
</div>

和样式:

.messages {
  height: 200px;
  overflow: auto;
}
.messages .timestamp {
  min-width: 75px;
}

问题似乎是 min-width 约束,但我需要它来防止第一列换行。我还需要将消息的高度限制为 200 像素。我无法在 .messages 上设置 overflow-x: hidden,因为它会切断内容。

最佳答案

这个怎么样:-

在最后一列使用 word-break 以避免它被截断。

word-break

Demo

.messages {
    height: 200px;
    overflow-y: auto;
    
}
.messages .timestamp {
    min-width: 75px;
}
.messages td:nth-child(3) {
    word-break:break-all; /* or use word-break:normal; if you don't want to get the word cut in between*/
   
}

这将根据可用宽度调整分词,而不隐藏内容。

关于css - 如何摆脱 Chrome 和 Safari 中的水平滚动条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16499495/

相关文章:

javascript - 我制作了一个 jquery 幻灯片放映但它不能正常工作,我该怎么办

html - DIV 换行,即使是 "display: inline-block"

CSS Positioning-Position 相对和绝对 Bootstrap

javascript - Bootstrap 选项卡与表格大小混淆

html - Bootstrap - 流向第二行的图标行(响应式)

javascript - jQuery Dropdown - 找出被点击的内容

javascript - 将选择器添加到动态生成的 <li> 元素中

javascript - 左右定位的奇怪结果不同

javascript - 滚动经过另一个 div 后让 div 停留在页面顶部?

css - rails : Alternative for bootstrap select?