Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> CSS

Căn chỉnh mục flex ở đầu container với CSS


Sử dụng thuộc tính justify-content với giá trị flex-start để căn chỉnh các mục flex ở đầu.

Bạn có thể chạy mã sau để triển khai giá trị flex-start:

Ví dụ

<!DOCTYPE html> <html>    <head>       <style>          .mycontainer {             display: flex;             background-color: red;             justify-content: flex-start;          }          .mycontainer > div {             background-color: orange;             text-align: center;             line-height: 60px;             font-size: 30px;             width: 100px;             margin: 5px;          }       </style>     </head>    <body>       <h1>Result</h1>       <div class = "mycontainer">          <div>Rank1</div>          <div>Rank2</div>          <div>Rank3</div>          <div>Rank4</div>       </div>    </body> </html>