css字母不到一行就换行的方法:1、给元素添加“word- br eak:break-word;”样式,使其以单词为单位换行;2、给元素添加“word-break:break-all;”样式,使其以字母为单位换行。
本教程操作环境:windows7系统、CSS3 && HT ML 5版、Dell G3 电 脑。
css字母不到一行就换行的方法
打开一个html代码页面,创建两个div标签并输入一段英文语句。分别设置按字母自动换行和按单词自动换行两种css样式。
word-break:break-word;//表示以单词为单位换行, word-break:break-all;//表示以字母为单位换行。
代码如下:
<!DOCTY PE html>
<html lang="en">
<head>
< ;m eta charset="UTF-8">
<meta n am e="viewport" content="width=device-width, in IT ial -s cale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie= Edge ">
<title>Document</title>
<style>
.aa{
width:150px;
word-break:break-word;
}
.bb{
width:150px;
word-break:break-all;
}
</style>
</head>
<body>
<div class="aa">When summer comes, unlike most people, I will be very excited, because I like summer very much. People don’t like summer because of its hot weather, which makes people sweat all the time. But summer is my favorite season, I can wear fewer clothes. I like to wear short jeans and a T-shirt, I feel so free.</div>
<div class="bb">When summer comes, unlike most people, I will be very excited, because I like summer very much. People don’t like summer because of its hot weather, which makes people sweat all the time. But summer is my favorite season, I can wear fewer clothes. I like to wear short jeans and a T-shirt, I feel so free.</div>
</body>
</html>输出结果:
以上便是两种不同的换行方式。
更多编程相关知识,请访问:编程视频!!
以上就是css 怎样 实现字母不到一行就换行的详细内容,更多请关注其它相关 文章 !
总结
以上是 为你收集整理的 css怎样实现字母不到一行就换行 全部内容,希望文章能够帮你解决 css怎样实现字母不到一行就换行 所遇到的问题。
如果觉得 网站内容还不错, 推荐好友。
查看更多关于css怎样实现字母不到一行就换行的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did200263