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

ห่อรายการแบบยืดหยุ่นในลำดับย้อนกลับด้วย CSS


ใช้ flex-wrap คุณสมบัติด้วย wrap-reverse ค่าที่จะห่อ flex-items ในลำดับย้อนกลับ

ตัวอย่าง

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

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: #D35400;
            flex-wrap: wrap-reverse;
         }
         .mycontainer > div {
            background-color: white;
            text-align: center;
            line-height: 40px;
            font-size: 25px;
            width: 100px;
            margin: 5px;
         }
      </style>
   </head>
   <body>
      <h1>Quiz</h1>
      <div class = "mycontainer">
         <div>Ans1</div>
         <div>Ans2</div>
         <div>Ans3</div>
         <div>Ans4</div>
         <div>Ans5</div>
         <div>Ans6</div>
         <div>Ans7</div>
         <div>Ans8</div>
         <div>Ans9</div>
      </div>
   </body>
</html>