[前端]div不换行

网友投稿 721 2022-10-07

[前端]div不换行

[前端]div不换行

参考:style="float:left;margin-left:50px">

display:inline;ORfloat:left;ORdisplay:inline-block; -- Might not work on all browsers.What is the purpose of using a div here? I'd suggest a span, as it is an inline-level element, whereas a div is a block-level element.Do note that each option above will work differently.display:inline; will turn the div into the equivalent of a span. It will be unaffected by margin-top, margin-bottom, padding-top, padding-bottom, height, etc.float:left; keeps the div as a block-level element. It will still take up space as if it were a block, however the width will be fitted to the content (assuming width:auto;). It can require a clear:left; for certain effects.display:inline-block; is the "best of both worlds" option. The div is treated as a block element. It responds to all of the margin, padding, and height rules as expected for a block element. However, it is treated as an inline element for the purpose of placement within other elements.Read this for more information.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信小程序:如何实现tabs选项卡效果示例
下一篇:微信小程序页面滑动屏幕加载数据的实例详解(微信小程序动态加载页面)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~