本文分享几个css实例,介绍下自动换行、强迫不换行的实现方法,学习下word-wrap: break-word、word-break: normal等的用法,有需要的朋友参考下吧。
1,自动换行
复制代码 代码示例:
div{
word-wrap:
break-word;
word-break: normal;
}
2,强迫不换行
复制代码 代码示例:
div{
white-space:nowrap;
}
3,带有浮动效果的 不换行:
复制代码 代码示例:
<div id="pic">
<ul>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/imgget1.jpg" /></li>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://www.jb200.com/hibeans/web/images/temporary/car_t1.jpg" /></li>
</ul>
</div>
css代码部分:
复制代码 代码示例:
#pic {float:left; width:920px; margin:0 10px;}
#pic ul {margin:15px 0; white-space:nowrap; width:920px; overflow:hidden;}
#pic li {*float:left; width:90px; margin:0 5px; *clear:right; border:1px solid #B7DEEF; text-align:center; display:inline-block}
#pic li img {max-width:90px; max-height:90px; vertical-align:middle;}