【问题标题】:How to insert a photo into bootstrap card panel如何将照片插入引导卡面板
【发布时间】:2021-05-15 07:06:40
【问题描述】:

一个我无法弄清楚的超级简单的问题。我是新手。如何在卡片标题中插入图像?我已经尝试了 30 分钟,但在网上找不到任何东西。我知道这是一个菜鸟问题。饶了我吧。任何帮助将不胜感激。

这是我要插入的图片:

https://media1.giphy.com/media/l0HlSBFa5Z9onGbcc/giphy.gif

我似乎无法将其正确放置在 rect 标记或 svg 标记中。任何帮助都可以。或者指向正确的方向。

<div class="album py-5 bg-light">
            <div class="container">

                <div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
                    <div class="col">
                        <div class="card shadow-sm">
                            <svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img"   aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#55595c" /><text x="50%" y="50%" fill="#eceeef" dy=".3em">Project 1</text></svg>
                                
                            <div class="card-body">
                                <p class="card-text">Click "View" to see my posted Project 1. Project 1 is my personal Student Feedback Form. When the form is submitted it will display to you the data inputted as well as give the course and professor a score.</p>
                                <div class="d-flex justify-content-between align-items-center">
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-sm btn-outline-secondary">View</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

感谢您抽出宝贵的时间。

【问题讨论】:

  • 不使用 SVG,为什么不尝试使用 Image-tag。 &lt;img src="/image.jpg" alt="Card Image"&gt;

标签: html css image bootstrap-4


【解决方案1】:
【解决方案2】:

只需替换这个:

<svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img"   aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#55595c" /><text x="50%" y="50%" fill="#eceeef" dy=".3em">Project 1</text></svg>

有了这个:

<img src="https://media1.giphy.com/media/l0HlSBFa5Z9onGbcc/giphy.gif">

完整代码:

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="album py-5 bg-light">
  <div class="container">

    <div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
      <div class="col">
        <div class="card shadow-sm">
          <img src="https://media1.giphy.com/media/l0HlSBFa5Z9onGbcc/giphy.gif">

          <div class="card-body">
            <p class="card-text">Click "View" to see my posted Project 1. Project 1 is my personal Student Feedback Form. When the form is submitted it will display to you the data inputted as well as give the course and professor a score.</p>
            <div class="d-flex justify-content-between align-items-center">
              <div class="btn-group">
                <button type="button" class="btn btn-sm btn-outline-secondary">View</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

在 Codepen 上查看它:https://codepen.io/manaskhandelwal1/pen/MWbbJPw?editors=1000

【讨论】:

  • 谢谢!这么多!
猜你喜欢
  • 1970-01-01
  • 2021-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-27
  • 1970-01-01
  • 2013-11-13
  • 1970-01-01
相关资源
最近更新 更多