Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

การจัดแสดง Flex Items พร้อมช่องว่างระหว่างบรรทัดใน CSS


ใช้คุณสมบัติ justify-content พร้อมค่า space-between เพื่อเพิ่มช่องว่างระหว่างบรรทัด

ตัวอย่าง

คุณสามารถลองรันโค้ดต่อไปนี้เพื่อนำค่า space-between ไปใช้ −

<!DOCTYPE html> <html>    <head>       <style>          .mycontainer {             display: flex;             background-color: red;             justify-content: space-between;          }          .mycontainer > div {             background-color: white;             text-align: center;             line-height: 60px;             font-size: 30px;             width: 100px;             margin: 5px;          }          </style>    </head>    <body>       <h1>Quiz</h1>       <div class = "mycontainer">          <div>Q1</div>          <div>Q2</div>          <div>Q3</div>          <div>Q4</div>       </div>    </body> </html>