• 技术文章 >web前端 >前端问答

    flex属于bootstrap吗

    WBOYWBOY2022-08-22 16:54:56原创268

    flex布局属于bootstrap;flex指的是弹性布局,bootstrap可以通过flex类来控制页面的布局,使用“.d-flex”和“.d-inline-flex”实现开启flex布局样式,能不能使用flex弹性布局也是bootstrap3和bootstrap4的最大区别。

    大前端成长进阶课程:进入学习

    本教程操作环境:Windows10系统、bootstrap5版、DELL G3电脑

    flex属于bootstrap

    Bootstrap4 通过 flex 类来控制页面的布局

    Bootstrap 3 与 Bootstrap 4 最大的区别就是 Bootstrap 4 使用弹性盒子来布局,而不是使用浮动来布局。

    示例如下:

    <div class="d-flex flex-row-reverse border border-dark mt-5 justify-content-center">
                <div class="p-2 border border-success">
                    1            </div>
                <div class="p-2 border border-success">
                    2            </div>
                <div class="p-2 border border-success">
                    3            </div>
            </div>
            <div class="d-flex flex-column-reverse border border-dark mt-5 justify-content-between" style="height: 200px;">
                <div class="p-2 border border-success">
                    1            </div>
                <div class="p-2 border border-success">
                    2            </div>
                <div class="p-2 border border-success">
                    3            </div>
            </div>
            <div class="d-flex  border border-dark mt-5 align-items-baseline" style="height: 200px;">
                <div class="p-2 border border-success align-self-center">
                    1            </div>
                <div class="p-2 border border-success">
                    2            </div>
                <div class="p-2 border border-success">
                    3            </div>
            </div>

    示例如下:

    <!DOCTYPE html>
    <html>
    <head>
      <title>Bootstrap 实例</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
      <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
      <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
      <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    </head>
    <body>
    <div class="container mt-3">
      <h2>Flex</h2>
      <p>使用 d-flex 类创建一个弹性盒子容器,并设置三个弹性子元素:</p>
      <div class="d-flex p-3 bg-secondary text-white">  
        <div class="p-2 bg-info">Flex item 1</div>
        <div class="p-2 bg-warning">Flex item 2</div>
        <div class="p-2 bg-primary">Flex item 3</div>
      </div>
    </div>
    </body>
    </html>

    输出结果:

    19.png

    相关推荐:bootstrap教程

    以上就是flex属于bootstrap吗的详细内容,更多请关注php中文网其它相关文章!

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

    前端(VUE)零基础到就业课程:点击学习

    清晰的学习路线+老师随时辅导答疑

    自己动手写 PHP MVC 框架:点击学习

    快速了解MVC架构、了解框架底层运行原理

    专题推荐:bootstrap
    上一篇:bootstrap实现的媒体对象是什么 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • ❤️‍🔥共22门课程,总价3725元,会员免费学• ❤️‍🔥接口自动化测试不想写代码?• bootstrap怎么清除浮动的样式• 什么是bootstrap自适应• 什么是bootstrap响应式• 什么是bootstrap栅格化• bootstrap是免费的吗
    1/1

    PHP中文网