赞
踩
在没有空格的(字母、数字,符号),超过容器宽度时就会把容器撑大,不换行。所以在这里需要对其设置强制换行的样式;
/* word-wrap: break-word; */ /* word-break: break-all; */
word-wrap: break-word; 如果一个单词在一行放不下,就会将它放到下一行;
word-break: break-all; 如果一个单词在一行放不下,就会将它截开;
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- .text{
- width: 306px;
- display: block;
- /* word-wrap: break-word; */
- /* word-break: break-all; */
- border: 3px solid skyblue;
- }
- </style>
- </head>
- <body>
- <p class="text">ffffffkfja1111111111111111111111111111111111111111skljfka</p>
- </body>
- </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。