in English

媒体对象

Bootstrap 媒体对象的文档和示例,用于构建高度重复的组件,如博客评论、推文等。

例子

媒体对象有助于构建复杂且重复的组件,其中一些媒体位于不环绕所述媒体的内容旁边。另外,多亏了 flexbox,它只需要两个必需的类就可以做到这一点。

下面是单个媒体对象的示例。只需要两个类 - 包装.media.media-body围绕您的内容。可以通过间距实用程序控制可选的填充和边距。

Placeholder 64x64
媒体标题

你会为我做同样的事吗?是时候面对音乐了,我不再是你的缪斯。听说它很漂亮,当评委,我的女孩们会投票。我能感觉到我体内有一只凤凰。天堂嫉妒我们的爱,天使从天而降。是的,你带我去乌托邦。

<div class="media">
  <img src="..." class="mr-3" alt="...">
  <div class="media-body">
    <h5 class="mt-0">Media heading</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>
Flexbug #12:内联元素不被视为弹性项目

Internet Explorer 10-11 不会将链接或图像(或伪元素)等内联元素呈现::before::after弹性项目。唯一的解决方法是设置一个非内联display值(例如,、、blockinline-blockflex。我们建议使用.d-flex我们的显示实用程序之一,作为一个简单的修复。

资料来源: GitHub 上的 Flexbugs

嵌套

媒体对象可以无限嵌套,但我们建议您在某个时候停下来。嵌套.media.media-body父媒体对象中。

Placeholder 64x64
媒体标题

当炸弹开始下落时站在前线。天堂嫉妒我们的爱,天使从天而降。不能用一百万个戒指代替你。男孩,当你和我在一起时,我会让你尝尝。回不去了。在你遇见我之前,我还好,但事情有点重。重是戴冠的头。

Placeholder 64x64
媒体标题

问候亲人,让我们一起旅行。是的,我们让天使哭泣,从天而降在地球上。给你一些好东西来庆祝。我过去常常咬着舌头屏住呼吸。我穿着紧身牛仔裤让你心跳加速。当我独自前进到不同的节拍时。高中毕业后的夏天,我们第一次见面。你这么催眠,你会是魔鬼吗?你能成为天使吗?是时候拿出大气球了。以为我是个例外。比基尼,西葫芦,马提尼酒,没有小妞。

<div class="media">
  <img src="..." class="mr-3" alt="...">
  <div class="media-body">
    <h5 class="mt-0">Media heading</h5>
    <p>Standing on the frontline when the bombs start to fall. Heaven is jealous of our love, angels are crying from up above. Can't replace you with a million rings. Boy, when you're with me I'll give you a taste. There’s no going back. Before you met me I was alright but things were kinda heavy. Heavy is the head that wears the crown.</p>

    <div class="media mt-3">
      <a class="mr-3" href="#">
        <img src="..." alt="...">
      </a>
      <div class="media-body">
        <h5 class="mt-0">Media heading</h5>
        <p>Greetings loved ones let's take a journey. Yes, we make angels cry, raining down on earth from up above. Give you something good to celebrate. I used to bite my tongue and hold my breath. I'm ma get your heart racing in my skin-tight jeans. As I march alone to a different beat. Summer after high school when we first met. You're so hypnotizing, could you be the devil? Could you be an angel? It's time to bring out the big balloons. Thought that I was the exception. Bikinis, zucchinis, Martinis, no weenies.</p>
      </div>
    </div>
  </div>
</div>

结盟

媒体对象中的媒体可以与 flexbox 实用程序对齐到内容的顶部(默认)、中间或末尾.media-body

Placeholder 64x64
顶部对齐的媒体

我要让她昏迷 你给出了一百个理由,然后你说你真的会尝试。于是我安静地坐着,礼貌地答应了。适合我的加冕之战。在我 18 岁生日那天,我们得到了匹配的纹身。如此时尚,是的,她是经典之作。我已准备好踏上少有人走的路。

我正在空中行走(今晚)。但脚踏实地。你是原创的,无法替代。但在另一种生活中,我会成为你的女孩。我们开车到卡利,在海滩上喝醉了。我们可以跳舞,直到我们死去,你和我,将永远年轻。看见你在市中心唱蓝调。

<div class="media">
  <img src="..." class="align-self-start mr-3" alt="...">
  <div class="media-body">
    <h5 class="mt-0">Top-aligned media</h5>
    <p>I’m gon’ put her in a coma. You give a hundred reasons why, and you say you're really gonna try. So I sat quietly, agreed politely. Suiting up for my crowning battle. And on my 18th Birthday we got matching tattoos. So très chic, yeah, she's a classic. I am ready for the road less traveled.</p>
    <p>I'm walking on air (tonight). But down to earth. You're original, cannot be replaced. But in another life I would be your girl. We drove to Cali and got drunk on the beach. We can dance, until we die, you and I, will be young forever. Saw you downtown singing the Blues.</p>
  </div>
</div>
Placeholder 64x64
居中对齐的媒体

她会像冰箱一样变冷。在这一切的最后。像蜜蜂一样刺痛我赢得了我的条纹。比基尼,西葫芦,马提尼酒,没有小妞。我希望你有一个健康的胃口。我们可以跳舞,直到我们死去,你和我,将永远年轻。我们过着这样的生活。我们做得对。街上的消息,你有东西要给我看,我。

想看3D电影。他们说,怕你不像其他人,未来的情人。敞开心扉。于是我安静地坐着,礼貌地答应了。上周五晚上。是的,如果你在她的飞机上,你很幸运。我会成为你的礼物,给你一些好东西来庆祝。

<div class="media">
  <img src="..." class="align-self-center mr-3" alt="...">
  <div class="media-body">
    <h5 class="mt-0">Center-aligned media</h5>
    <p>She'll turn cold as a freezer. At the eh-end of it all. Stinging like a bee I earned my stripes. Bikinis, zucchinis, Martinis, no weenies. I hope you got a healthy appetite. We can dance, until we die, you and I, will be young forever. We're living the life. We're doing it right. Word on the street, you got somethin' to show me, me.</p>
    <p class="mb-0">Wanna see the show in 3D, a movie. They say, be afraid you're not like the others, futuristic lover. Open up your heart. So I sat quietly, agreed politely. Last Friday night. Yeah, you're lucky if you're on her plane. I'll be your gift, give you something good to celebrate.</p>
  </div>
</div>
Placeholder 64x64
底部对齐的媒体

来吧,让你的颜色爆发。我能感觉到我内心的光。他们整晚都在演奏,你的歌。从东京到墨西哥,再到里约。回不去了。但脚踏实地。神奇,多彩,神秘先生,嗯。不同的DNA,他们不了解你。

但脚踏实地。她明白了,je ne sais quoi,你知道的。我可以看到墙上的文字。男孩们扭断脖子试图偷偷偷看。带我,ta-ta-带我。敞开心扉。以为我是个例外。轰,轰,轰。威尼斯海滩和棕榈泉,夏天就是一切。把节拍带回来。(这是我们如何做到)

<div class="media">
  <img src="..." class="align-self-end mr-3" alt="...">
  <div class="media-body">
    <h5 class="mt-0">Bottom-aligned media</h5>
    <p>Come on, let your colours burst. I can feel this light that's inside of me. All night they're playing, your song. From Tokyo to Mexico, to Rio. There’s no going back. But down to earth. Magical, colorful, Mr. Mystery, ee. Different DNA, they don't understand you.</p>
    <p class="mb-0">But down to earth. She's got that, je ne sais quoi, you know it. I can see the writing on the wall. The boys break their necks try'na to creep a little sneak peek. Take me, ta-ta-take me. Open up your heart. Thought that I was the exception. Boom, boom, boom. Venice beach and Palm Springs, summertime is everything. Bring the beat back. (This is how we do)</p>
  </div>
</div>

命令

order通过修改 HTML 本身或添加一些自定义 flexbox CSS 来设置属性(为您选择的整数)来更改媒体对象中的内容顺序。

媒体对象

我知道会有牺牲,但这就是代价。你有勇气让我看到你的孔雀吗?今晚成为你的少年梦想。嗯嗯,看见了 回不去了。是的,我们刷爆了信用卡,然后被赶出了酒吧。所以让我给你穿上你的生日套装。当你遇到她时,你可能会坠入爱河。世界尽在掌中。不要让伟大让你失望,哦,哦,是的。现在我们谈论占星术,做我们的指甲,都是日本人。让我成为你的阿芙罗狄蒂。

Placeholder 64x64
<div class="media">
  <div class="media-body">
    <h5 class="mt-0 mb-1">Media object</h5>
    <p>I know there will be sacrifice but that's the price. Are you brave enough to let me see your peacock? Be your teenage dream tonight. Uh-huh, I see you. There’s no going back. Yeah, we maxed our credit cards and got kicked out of the bar. So let me get you in your birthday suit. You may fall in love when you meet her. Had the world in the palm of your hands. Don't let the greatness get you down, oh, oh yeah. Now we talking astrology, getting our nails did, all Japanese-y. Make me your Aphrodite.</p>
  </div>
  <img src="..." class="ml-3" alt="...">
</div>

媒体列表

因为媒体对象的结构要求很少,所以您也可以在列表 HTML 元素上使用这些类。在您的<ul>or<ol>上,添加.list-unstyled以删除任何浏览器默认列表样式,然后应用于.media<li>的 s. 与往常一样,在需要微调的地方使用间距实用程序。

  • Placeholder 64x64
    基于列表的媒体对象

    我所有的女孩都是复古香奈儿宝贝。这样你就可以吃蛋糕了。今晚,今晚,今晚,我在空中行走。慢慢吞下我的恐惧,是的,是的。快速成长为一道闪电。如此炎热和沉重,直到黎明。那个以穿着闪亮盔甲的骑士结尾的童话。重是戴冠的头。

  • Placeholder 64x64
    基于列表的媒体对象

    也许是所有门都关闭的原因。因为一旦你是我的,一旦你是我的。今晚成为你的少年梦想。重是戴冠的头。这甚至不是一个节日,没有什么可庆祝的。完美风暴,完美风暴。

  • Placeholder 64x64
    基于列表的媒体对象

    你有勇气让我看到你的孔雀吗?回不去了。这是你最后一次说,在你打破最后一行之后。在这一切的最后。

<ul class="list-unstyled">
  <li class="media">
    <img src="..." class="mr-3" alt="...">
    <div class="media-body">
      <h5 class="mt-0 mb-1">List-based media object</h5>
      <p>All my girls vintage Chanel baby. So you can have your cake. Tonight, tonight, tonight, I'm walking on air. Slowly swallowing down my fear, yeah yeah. Growing fast into a bolt of lightning. So hot and heavy, 'Til dawn. That fairy tale ending with a knight in shining armor. Heavy is the head that wears the crown.</p>
    </div>
  </li>
  <li class="media my-4">
    <img src="..." class="mr-3" alt="...">
    <div class="media-body">
      <h5 class="mt-0 mb-1">List-based media object</h5>
      <p>Maybe a reason why all the doors are closed. Cause once you’re mine, once you’re mine. Be your teenage dream tonight. Heavy is the head that wears the crown. It's not even a holiday, nothing to celebrate. A perfect storm, perfect storm.</p>
    </div>
  </li>
  <li class="media">
    <img src="..." class="mr-3" alt="...">
    <div class="media-body">
      <h5 class="mt-0 mb-1">List-based media object</h5>
      <p>Are you brave enough to let me see your peacock? There’s no going back. This is the last time you say, after the last line you break. At the eh-end of it all.</p>
    </div>
  </li>
</ul>