CSS nowrap for other than text elements?

扶醉桌前 提交于 2019-12-22 01:25:25

问题


Is there a way to avoid wrapping of a div's content when the content is not just text e.g. several buttons?


回答1:


white-space:nowrap; should do the trick.

#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




回答2:


You can set both these properties in CSS:

white-space:nowrap; and max-width:something;




回答3:


You can declare static positions for the other contents using

position:absolute;


来源:https://stackoverflow.com/questions/15857321/css-nowrap-for-other-than-text-elements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!