首页 > 其他分享 >Bootstrap5 如何创建多媒体对象

Bootstrap5 如何创建多媒体对象

时间:2022-10-02 19:33:05浏览次数:49  
标签:me 多媒体 媒体 创建 gonna take crying 对齐 Bootstrap5

一、在Bootstra5中使用媒体对象


Bootstrap 媒体对象在版本 5 中已经停止支持了。但是,我们仍然可以使用 flex 和 margin 创建包含左对齐或右对齐媒体对象(如图像或视频)以及文本内容(如博客评论、推文等)的布局 。

<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>

</head>
<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-2"></div>
        <div class="col-md-8">
        <br>
        <div class="d-flex">
            <div class="flex-shrink-0">
                <img src="img/xyz.png" class="rounded-circle" alt="Sample Image">
            </div>
            <div class="flex-grow-1 ms-3">
                <h5>Bootstrap 5 <small class="text-muted"><i>[email protected]</i></small></h5>
                <p>Will you do the same for me? It's time to face the music I'm no longer your muse. Heard it's beautiful, be the judge and my girls gonna take a vote. I can feel a phoenix inside of me. Heaven is jealous of our love, angels are crying from up above. Yeah, you take me to utopia.</p>
            </div>
        </div>
        <div class="col-md-2"></div>
    </div>
 </div>
</body>
</html>

显示的结果如下

我们还可以创建媒体对象的其他变体。

将 .rounded 或 .rounded-circle 等图像修饰符类应用于图像来创建圆角或圆形图像。

<div class="d-flex">
    <div class="flex-shrink-0">
        <img src="img/xyz.png" class="rounded-circle" alt="Sample Image">
    </div>
    <div class="flex-grow-1 ms-3">
        <h5>Bootstrap 5 <small class="text-muted"><i>[email protected]</i></small></h5>
        <p>Will you do the same for me? It's time to face the music I'm no longer your muse. Heard it's beautiful, be the judge and my girls gonna take a vote. I can feel a phoenix inside of me. Heaven is jealous of our love, angels are crying from up above. Yeah, you take me to utopia.</p>
    </div>
</div>

显示的结果如下

二、创建嵌套的媒体对象


媒体对象也可以嵌套在其他媒体对象中。

<div class="d-flex">
    <div class="flex-shrink-0">
        <img src="img/xyz.png" class="rounded-circle" alt="Sample Image">
    </div>
    <div class="flex-grow-1 ms-3">
        <h5>Bootstrap 5 <small class="text-muted"><i>[email protected]</i></small></h5>
        <p>Will you do the same for me? It's time to face the music I'm no longer your muse. Heard it's beautiful, be the judge and my girls gonna take a vote. I can feel a phoenix inside of me. Heaven is jealous of our love, angels are crying from up above. Yeah, you take me to utopia.</p>

        <!-- Nested media object -->
        <div class="d-flex mt-4">
            <div class="flex-shrink-0">
                <img src="img/xyz.png" class="rounded-circle" alt="Sample Image">
            </div>
            <div class="flex-grow-1 ms-3">
                <h5>Bootstrap 5 <small class="text-muted"><i>[email protected]</i></small></h5>
                <p>Will you do the same for me? It's time to face the music I'm no longer your muse. Heard it's beautiful, be the judge and my girls gonna take a vote. I can feel a phoenix inside of me. Heaven is jealous of our love, angels are crying from up above. Yeah, you take me to utopia.</p>
            </div>
        </div>
    </div>
</div>

嵌套媒体对象显示的结果如下

 

三、媒体对象对齐


我们还可以通过简单地调整 HTML 代码本身来更改内容以及媒体对象的水平对齐方式。

<div class="d-flex">
     <div class="flex-grow-1 me-3">
         <h5>Bootstrap 5 <small class="text-muted"><i>[email protected]</i></small></h5>
         <p>Will you do the same for me? It's time to face the music I'm no longer your muse. Heard it's beautiful, be the judge and my girls gonna take a vote. I can feel a phoenix inside of me. Heaven is jealous of our love, angels are crying from up above. Yeah, you take me to utopia.</p>
     </div>
     <div class="flex-shrink-0">
         <img src="img/xyz.png" alt="Sample Image">
     </div>
</div>

显示的结果如下

除此之外,我们还可以使用 flexbox 实用程序类在内容块的中间或底部对齐图像或其他媒体对象,例如,可以使用 .align-self-center 类进行垂直居中对齐,使用 .align-self-end 类用于底部对齐。

默认情况下,媒体对象内的媒体是顶部对齐的。

<!--顶部对齐媒体-->
<div class="d-flex">
    <div class="flex-shrink-0">
        <img src="img/xyz.png" width="60" height="60" alt="Sample Image">
    </div>
    <div class="flex-grow-1 ms-3">
        <h5>顶部对齐媒体 <small class="text-muted"><i>- 这是默认对齐方式</i></small></h5>
        <p>Will you do the same for me? It's time to face the music I'm no longer your muse. Heard it's beautiful, be the judge and my girls gonna take a vote. I can feel a phoenix inside of me. Heaven is jealous of our love, angels are crying from up above. Yeah, you take me to utopia.</p>
    </div>
</div>
<hr>

<!--居中对齐媒体-->
<div class="d-flex">
    <div class="flex-shrink-0 align-self-center">
        <img src="img/xyz.png" width="60" height="60" alt="Sample Image">
    </div>
    <div class="flex-grow-1 ms-3">
        <h5>居中对齐媒体</h5>
        <p>Will you do the same for me? It's time to face the music I'm no longer your muse. Heard it's beautiful, be the judge and my girls gonna take a vote. I can feel a phoenix inside of me. Heaven is jealous of our love, angels are crying from up above. Yeah, you take me to utopia.</p>
    </div>
</div>
<hr>

<!--底部对齐媒体-->
<div class="d-flex">
    <div class="flex-shrink-0 align-self-end">
        <img src="img/xyz.png" width="60" height="60" alt="Sample Image">
    </div>
    <div class="flex-grow-1 ms-3">
        <h5>底部对齐媒体</h5>
        <p>Will you do the same for me? It's time to face the music I'm no longer your muse. Heard it's beautiful, be the judge and my girls gonna take a vote. I can feel a phoenix inside of me. Heaven is jealous of our love, angels are crying from up above. Yeah, you take me to utopia.</p>
    </div>
</div>

 显示的结果如下

来自迹*客

 

标签:me,多媒体,媒体,创建,gonna,take,crying,对齐,Bootstrap5
From: https://www.cnblogs.com/huaxiayuyi/p/16749239.html

相关文章

  • Admin 创建
    admin:是一个账号管理系统,路由器管理系统以及网站管理系统等等都会将admin作为默认的一种登录名,创建属于自己的管理系统。下面是一个简单的商品管理系统:fromdjango.contrib......
  • 如何在 Linux 上创建可启动的 U 盘
    注意:以下命令需在root权限下执行,使用不当可能会损坏硬盘数据以及操作系统使用下列命令行请将<usb_drive>替换为设备名称,将<file.iso>替换为镜像文件的路径。您可用df、......
  • Svelte创建组件小结
    ·使用由HTML元素构成的简单易用语法来定义Svelte组件。script元素包含组件逻辑,style元素包含CSS样式,剩下的就是HTML标记。·向组件传递数据的常用方式是使用props。·Sv......
  • 004 反射机制——反射机制概念——Java的反射API——反射的步骤——创建对象的2种方式
    2.3.2反射机制的概念(什么是反射)反射机制指在程序运行过程中,对任意一个类都能获取其所有属性和方法,并且任意一个对象都能调用其任意一个方法。这种动态获取类和对象的信......
  • 创建web项目
    不使用web骨架的方式创建maven项目--》在pom.xml里面设置packaging为war的方式---》点击file--》projectstructure--》facets在此页面设置  使用骨架......
  • 在UE4中创建蓝图类,点开蓝图类没有编辑界面
    UE4系列文章目录文章目录​​UE4系列文章目录​​​​前言​​​​一、解决办法​​​​总结​​前言当我们在UE4的内容浏览器中新建了蓝图类,例如AKM_Bullet_BP,第一次点开这......
  • 多媒体元素
    多媒体元素video视频audio音频videocontorls:控制控件的显示,取值只能为contorls某些属性,只有两种状态:不写取值为属性名这种属性叫做布尔属性布尔属性在HTM......
  • 创建和初始化对象、构造函数详解
    创建和初始化对象、构造函数详解使用new关键字创建对象使用new关键字创建的时候,不仅会分配内存空间,还会进行默认的初始化以及调用类中的构造器packageoop.subject;......
  • idea中创建maven工程项目
    参考:maven安装及配置(详细版)_普通网友的博客-CSDN博客_maven配置idea配置maven项目(超详细)_普通网友的博客-CSDN博客_idea配置maven以下记录本人电脑操作1、下载maven免安装......
  • Netty 学习(六):创建 NioEventLoopGroup 的核心源码说明
    Netty学习(六):创建NioEventLoopGroup的核心源码说明作者:Grey原文地址:博客园:Netty学习(六):创建NioEventLoopGroup的核心源码说明CSDN:Netty学习(六):创建NioEventLoopG......