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

จัดแนวรายการแบบยืดหยุ่นที่ส่วนท้ายของคอนเทนเนอร์ด้วย CSS


ใช้ justify-content คุณสมบัติที่มีค่า flex-end เพื่อจัดตำแหน่ง flex-items ในตอนท้าย

ตัวอย่าง

คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้ค่า flex-end -

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: red;
            justify-content: flex-end;
         }
         .mycontainer > div {
            background-color: #E6B0AA;
            text-align: center;
            line-height: 60px;
            font-size: 30px;
            width: 100px;
            margin: 5px;
         }
      </style>
   </head>
   <body>
      <h1>Score</h1>
      <div class = "mycontainer">
         <div>20</div>
         <div>35</div>
         <div>88</div>
         <div>62</div>
      </div>
   </body>
</html>