flex-grow、flex-shrink 和 flex-basis 屬性的 CSS 簡寫屬性


使用 flex 屬性可在一行中新增 flex-grow、flex-shrink 和 flex-basis 屬性。

可以透過執行以下程式碼來嘗試實現 flex 屬性

示例

現場演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         .mycontainer {
            display: flex;
            background-color: orange;
         }
         .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>Q1</div>
         <div>Q2</div>
         <div>Q3</div>
         <div style = "flex: 20 0 350px">Q4</div>
         <div>Q5</div>
         <div>Q6</div>
         <div>Q7</div>
         <div>Q8</div>
         <div>Q9</div>
      </div>
   </body>
</html>

更新日期:2020 年 6 月 24 日

147 次瀏覽

開啟職業生涯

透過完成課程獲取認證

開始
廣告
© . All rights reserved.