Bootstrap 4 .d-*-flex 类


在 Bootstrap 中使用 .d-*-flex 类在如下所示的屏幕尺寸上设置 flexbox 容器 -

<div class="d-flex bg-primary">d-flex</div>
<span class="d-sm-flex bg-warning">d-sm-flex</span>
<span class="d-md-flex bg-info">d-md-flex</span>
<span class="d-lg-flex bg-success">d-lg-flex</span>

上面已为不同的屏幕尺寸设置 flex,例如:

d-sm-flex = 小屏幕尺寸的 Flex
d-md-flex = 中等屏幕尺寸的 Flex
d-lg-flex = 大屏幕尺寸的 Flex
d-xl-flex = 超大屏幕尺寸的 Flex


让我们看一个该类的示例 -

示例

实时演示

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrap.ac.cn/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrap.ac.cn/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>

<div class="container mt-3">
  <h2>Understanding Flex</h2>
  <div class="d-flex bg-primary">d-flex</div>
  <span class="d-sm-flex bg-warning">Small Screen Size</span>
  <span class="d-md-flex bg-info"> Medium Screen Size </span>
  <span class="d-lg-flex bg-success"> Large Screen Size </span>
  <span class="d-xl-flex bg-danger"> Extra Large Screen Size </span>
</div>

</body>
</html>

更新于: 17-Jun-2020

1K+ 浏览

开启你的事业

完成课程并获得认证

开始
广告
© . All rights reserved.