html - 如何在css背景图像中放入一个div 2图像:url(.....)
问题描述
如何在背景中使用 css 将两个图像放在同一个 div 中?
<div class="testimonial carousel-item active">
<img class="img-testimonial" src="assets/image-tanya.jpg" alt="">
<div class="text-testimonial">
<p>"I've been interested in coding for a while but never taken the jump, until now. I couldn't recommend this course enough. I'm now in the job of my dreams and so excited about the future."</p>
<p class="small">Tanya Sinclair <span class="grey">UX Engineer</span></p>
</div>
</div>
在 .testimonial 我在后台有一个 svg 图像
.testimonial {
background-image: url(../pattern-bg.svg);
background-repeat: no-repeat;
background-position: right top;
width: 1000px;
height: 800px;
position: relative;
display: inline-block;
}
解决方案
CSS 允许您通过 background-image 属性为一个元素添加多个背景图像。
不同的背景图像用逗号分隔,图像相互堆叠,其中第一张图像最靠近观看者。
div{
background-image: url("https://whyy.org/wp-content/uploads/2017/07/LOGO_First_overwhite-1-copy-1024x444.png"), url("https://cdn.iconscout.com/icon/premium/png-256-thumb/2nd-place-594924.png");
background-repeat: no-repeat;
background-position: left top;
width: 1000px;
height: 800px;
position: relative;
display: inline-block;
}
<div></div>
推荐阅读
- javascript - websocket对象未在本机反应中连接套接字
- reactjs - React单选按钮无法呈现选中状态
- python - 如何将代理添加到 quickstart.py-python
- json - 如何使用 `pandas.to_sql` 将 `dict` 列推入 Redshift SUPER 类型列?
- php - 在 Laravel 8 的用户表中更改名称列“created_at”和“updated_at”
- pytorch - 如何拥有一个从多个数据集中获取批次的数据加载器,但每个批次只能包含来自一个数据集的元素?
- python - 将变量传入和传出 exec
- postgresql - PostgreSQL:ON CONFLICT DO UPDATE 命令不能再次影响行
- swift - 如何将 Firebase 格式错误显示为警报并将其显示给用户?
- javascript - 如何找到剩余时间 - JavaScript?