Bootstrap 4 .d-*-flex 类
bootstrapweb developmentcss framework更新于 2024/1/19 6:36:17
使用 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.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/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>

