如何在 CSS 中处理 Flexbox 元素?


定义一个 flex 容器并在其中设置 flex 元素。

你可以尝试运行以下代码来学习如何实现 Flexbox 元素。这里的 Q1、Q2、Q3 是 flex 元素。整个区域都是 Flexbox 元素

示例

现场演示

<!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>Q4</div>
         <div>Q5</div>
         <div>Q6</div>
      </div>
   </body>
</html>

更新于: 2020-06-25

138 次浏览

开启你的 职业生涯

通过完成课程获得认证

开始
广告
© . All rights reserved.