关于CSS中的自动换行和强制不换行
自定换行:
div{
word-wrap: break-word;
word-break: normal;
}
原始效果图展示:
这是网站上很常见的分享卡片,但是“。。。”并没有换行,这时候,我们就需要给div的样式设置为自定义换行,也就是word-wrap: break-word; word-break: normal;
修改后效果图展示:
修改后“。。。”就可以竖向显示了。
《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《《
强制不换行:
div{
white-space:nowrap;
}
代码展示:
<div id="pic">
<ul>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/imgget1.jpg" /></li>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/car_t1.jpg" /></li>
<li><img src="http://192.168.1.103/hibeans/web/images/temporary/car_t1.jpg" /></li>
</ul>
</div>
定义了强制不换行后超出可视区域的部分将在页面中自定显示滚动条,不换行。
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步