CSS中white-space属性

white-space 规定段落中的文本是否进行换行:
在这里插入图片描述

<!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>white-space</title>
    <style>
        div{
     
     
            width:260px;
            border: 1px solid #000;
            margin-bottom: 10px;
            color:sandybrown;
        }
        div:nth-child(1){
     
     
            white-space: normal;
        }
        div:nth-child(2){
     
     
            white-space: pre;
        }
        div:nth-child(3){
     
     
            white-space: nowrap;
        }
        div:nth-child(4){
     
     
            white-space: pre-line;
        }
        div:nth-child(5){
     
     
            white-space: pre-wrap;
        }
        div:nth-child(6){
     
     
            white-space: inherit;
        }
    </style>
</head>

<body>
     <div calss="div1">生活很苦但你很甜,要努力做个快乐的女孩子,奥利给</div>
     <div calss="div2">生活很苦但你很甜,要努力做个快乐的女孩子,奥利给</div>
     <div calss="div3">生活很苦但你很甜,要努力做个快乐的女孩子,奥利给</div>
     <div calss="div4">生活很苦但你很甜,要努力做个快乐的女孩子,奥利给</div>
     <div calss="div5">生活很苦但你很甜,要努力做个快乐的女孩子,奥利给</div>
     <div calss="div6">生活很苦但你很甜,要努力做个快乐的女孩子,奥利给</div>
</body>
</html>

效果图:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_45695853/article/details/115213223