CSS nowrap 用于文本元素以外的其他元素?

标签 css html nowrap

有没有办法避免 div 的换行 当内容不仅仅是文本时的内容,例如几个按钮?

最佳答案

white-space:nowrap; 应该可以解决问题。

#foo {
  white-space:nowrap;
  width: 100px;
}
<div id="foo">
  <input type="button" value="hello"/>
  <input type="button" value="hello"/>
  <input type="button" value="hello"/>
  <input type="button" value="hello"/>
  <input type="button" value="hello"/>
  <input type="button" value="hello"/>
  <input type="button" value="hello"/>
</div>

Demo

关于CSS nowrap 用于文本元素以外的其他元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15857321/

相关文章:

javascript - 从 html 中删除 div - jQuery

html - 如何在最新版本的主要浏览器中规范化 flex 元素的隐含最小宽度

javascript - HTML/HTA 文档中鼠标位置的实时更新

javascript - 图像上的版权文本在 html 中变得困惑

html - 空白 :nowrap breaks display:table

html - 当事件时会改变背景

html - 我应该如何将这些按钮放在 table 的右侧?

javascript - 两个按钮显示相同的 div。一键查看更多选项

html - 如何使用 css 在一行中获取所有图像(允许重叠)?

css - 另一个带有 "white-space: nowrap;"的 div 的背景不覆盖所有宽度