大佬教程收集整理的这篇文章主要介绍了CSS div左右浮动nowrap,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
问题是:
即使我有一个div float:left和一个div float:右边都有display:inline-block,而parent有white-space:没有换行 – 换行!!!我偶然发现我可以通过使用display:inline-block封闭另一个div来实现它.为什么是这样???
下面是我的代码和一个工作jsfiddle,以显示工作设置和包装设置.我不明白为什么我需要额外的div.
http://jsfiddle.net/klyngbaek/tNHLL/9/
当我缩小窗口时,我不希望第二个蓝色矩形下降到一个新行
HTML:
<h2>With extra inline-block dive. The blue rectangles do not wrap.</h2> <div class="wrapper nowrap"> <div class="second-wrapper"> <div class="floaTing float-left">[logo] | home | [navitem1] | [navitem2]</div> <div class="floaTing float-right">[username] | logout</div> </div> </div> <h2>Without extra inline-block dive. The blue rectangles do wrap.</h2> <div class="wrapper nowrap"> <div class="floaTing float-left">[logo] | home | [navitem1] | [navitem2]</div> <div class="floaTing float-right">[username] | logout</div> <div class="clearfix"></div> </div>
CSS:
.wrapper { border:#333; margin-bottom:; } .second-wrapper { border:; display:inline-block; min-width: 100%; } .nowrap { white-space: nowrap; } .clearfix { clear: both; } .floaTing { BACkground: lightblue; border:; height:; padding:} .float-left { float: left; } .float-right { float: right }
或者也许有更好的方法来实现我想要的.
提前致谢!
编辑:更新的jsfiddle链接
结果:
样式和HTML在一个文件中:
<html> <body> <style> .row { float:left; border: 3px solid blue; width: 96%; margin-left: 2%; margin-right: 2%; height: 115px; overflow: auto; position: static; } .floatLeftDiv { display: inline-block; border: 3px solid red; width: 200px; height: 100px; margin-top: 3px; } .right { float: right; border: 3px solid red; width: 200px; height: 100px; margin-top: 3px; margin-right: 1%; } </style> <div class="row"> <div class="floatLeftDiv" style="margin-left: 1%;">Inline Item A:</div> <div class="floatLeftDiv">Inline Item B:</div> <div class="floatLeftDiv">Inline Item C:</div> <div class="right">Inline Item D:</div> </div> </body> </html>
代码从此讨论中修改而另一个.
以上是大佬教程为你收集整理的CSS div左右浮动nowrap全部内容,希望文章能够帮你解决CSS div左右浮动nowrap所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。