浮动元素一行显示

代码:

<!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>
         div{
               float: left;
               width: 200px;
               height: 200px;
               background-color: pink;
         }

         .two{
               background-color: purple;
         }

         .four{
               background-color: skyblue;
         }
    </style>
</head>

<body>
         <div>1</div>
         <div class="two">2</div>
         <div>3</div>
         <div class="four">4</div>
</body>

</html>

运行效果

 

猜你喜欢

转载自blog.csdn.net/weixin_42900834/article/details/123907964