如何使用Bootstrap在英雄单元中显示缩略图?

发布于 2025-01-08 01:24:32 字数 1096 浏览 1 评论 0原文

在 Bootstrap 文档的此页面上,提供了一个示例来演示“英雄单元”通常放置在页面顶部并宣布一些重要信息。我正在尝试将其合并到页面中,但我还想在其旁边显示一个缩略图。这是我所拥有的:

<div class="hero-unit">
  <div class="thumbnail span3">
    <img src="http://placehold.it/260x180" alt="Sample Image">
  </div>
  <h1>Important Site Information</h1>
  <p>This paragraph contains important ... </p>
  <p><a class="btn btn-primary btn-large">Learn more &raquo;</a></p>
</div>

几乎有效,但缩略图和文本之间没有间隙:

在此处输入图像描述

此外,图像溢出了 hero-unit div。我意识到我可以通过一些内联样式来解决这两个问题:

<div class="hero-unit" style="overflow: auto;">
...
<div class="thumbnail span3" style="margin-right: 20px;">

但是,内联样式确实并不理想,我犹豫是否通过编辑 bootstrap.css 在站点范围内应用它。有更好的办法吗?我确信以前有人遇到过这个问题。

On this page of the Bootstrap documentation, an example is provided demonstrating the "hero unit" which typically is placed at the top of a page and announces something important. I am trying to incorporate this into a page but I would like to also display a thumbnail beside it. Here is what I have:

<div class="hero-unit">
  <div class="thumbnail span3">
    <img src="http://placehold.it/260x180" alt="Sample Image">
  </div>
  <h1>Important Site Information</h1>
  <p>This paragraph contains important ... </p>
  <p><a class="btn btn-primary btn-large">Learn more »</a></p>
</div>

This almost works but there is no gap between the thumbnail and the text:

enter image description here

Also, the image is overflowing the hero-unit div. I realize I can fix both issues with some inline styling:

<div class="hero-unit" style="overflow: auto;">
...
<div class="thumbnail span3" style="margin-right: 20px;">

However, inline styling really isn't ideal and I am hesitant to apply it site-wide by editing bootstrap.css. Is there a better way? I'm sure someone has run into this before.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千仐 2025-01-15 01:24:32

您可以嵌套网格元素。因此,只需在英雄单元内添加另一个

(或

),然后添加两个

块,其占整体网格列单位的适当百分比。

将图像放在左栏中,将文本放在右栏中。

You can nest grid elements. So just add another <div class="row-fluid"> (or <div class="row">) inside the hero unit, and then add two <div class="span..."> blocks with the appropriate percent of the overall grid column units.

Put the image in the left column, and the text in the right.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文