html - 使用 Bootstrap 的产品示例并试图弄清楚我如何添加图像
问题描述
我正在使用 Bootstrap 4 并使用他们的产品示例作为基础:https ://getbootstrap.com/docs/4.4/examples/product/
我试图弄清楚如何将白色和灰色背景区域更改为产品的实际照片。完整的代码片段如下,但我试图更改为响应式图像的彩色块是:
<div class="bg-dark shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
完整代码片段:
<div class="d-md-flex flex-md-equal w-100 my-md-3 pl-md-3">
<div class="bg-light mr-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
<div class="my-3 p-3">
<h2 class="display-5">Another headline</h2>
<p class="lead">And an even wittier subheading.</p>
</div>
<div class="bg-dark shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
</div>
<div class="bg-primary mr-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center text-white overflow-hidden">
<div class="my-3 py-3">
<h2 class="display-5">Another headline</h2>
<p class="lead">And an even wittier subheading.</p>
</div>
<div class="bg-light shadow-sm mx-auto" style="width: 80%; height: 300px; border-radius: 21px 21px 0 0;"></div>
</div>
</div>
解决方案
您可以在 div 中使用图像,如下所示:
<div class="d-md-flex flex-md-equal w-100 my-md-3 pl-md-3">
<div class="bg-light mr-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
<div class="my-3 p-3">
<h2 class="display-5">Another headline</h2>
<p class="lead">And an even wittier subheading.</p>
</div>
<div class="bg-white shadow-sm mx-auto screenshot-card">
<img style="height:auto;width:100%" src="/images/1.png", class="mx-auto w-65 lg:w-81">
</div>
</div>
<div class="bg-light mr-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center overflow-hidden">
<div class="my-3 py-3">
<h2 class="display-5">Another headline</h2>
<p class="lead">And an even wittier subheading.</p>
</div>
<div class="bg-white shadow-sm mx-auto screenshot-card">
<img style="height:auto;width:100%" src="/images/1.png", class="mx-auto w-65 lg:w-81">
</div>
</div>
</div>
您可以将以下课程用于屏幕截图卡
.screenshot-card {
width: 80%;
height: 100%;
border-radius: 21px 21px 0 0;
}
推荐阅读
- android - 将语音转文本字符串解码为日期和时间
- python - Python套接字:广播后未收到UDP响应
- mqtt - 多次发布蚊子,子只读上次发布
- php - PHP - 在看似复杂的数组中使用相同的键隔离元素
- apache-spark - 使用 Jupyter Notebook 进行 PySpark 配置
- macos - 如何在 Homebrew 上使用 Guile 2.0 进行编译?
- python-3.x - 如何在我的 .virtualenv 中执行我的 glob 命令
- sapui5 - SAPUI5 了解 manifest.json:rootView 以及如何将页面分配给应用程序
- python - 使用pypyodbc、pymssql、pyodbc的优缺点是什么?
- javascript - 将年转换为年、月、日、小时、分钟、秒