html - 如何将自定义边边框设置为图像并使其显示在其他图像上?
问题描述
下面是我已经实现的边界部分。现在如何重叠图像并设置边框如下图。
下面是我的代码。
<!DOCTYPE html>
<html>
<head>
<style>
.img1 {
border: 15px solid transparent;
background:
linear-gradient(#faa633, #faa633)
top left/ /* position */
50% 50% /* width height */
border-box no-repeat;
z-index: 1
}
.img2{
border: 15px solid transparent;
background:
linear-gradient(#faa633, #faa633)
top right/ /* position */
50% 100% /* width height */
border-box no-repeat;
z-index: 2
}
</style>
</head>
<body>
<img src="https://picsum.photos/id/10/200/150" class="img1">
<img src="https://picsum.photos/id/10/200/150" class="img2" >
</body>
</html>
解决方案
你必须使用颜色:before
请检查下面的代码
.outer {
display: flex;
align-items: flex-end;
}
img{max-width: 100%}
.img1 {
position: relative;
padding: 20px 0 0 20px;
float: left;
top: 90px;
margin-right: -90px;
width: 180px;
z-index: 1;
}
.img2{
position: relative;
float: left;
padding: 20px 20px 0 0;
width: 400px;
border-bottom: 20px solid red;
}
.img1 img, .img2 img{
position: relative;
display: block;
}
.img1:before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 110px;
height: 120px;
background: red;
display: block;
}
.img2:before{
content: "";
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 100%;
background: red;
display: block;
}
<div class="outer">
<div class="img1"><img src="https://webmeup.com/upload/blog/lead-image-105.png"></div>
<div class="img2"> <img src="https://cdn.pixabay.com/photo/2015/02/24/15/41/dog-647528__340.jpg">
</div>
</div>
希望!它适合你
推荐阅读
- vba - 如何使用VBA总结excel中的行
- node.js - Azure Function Runtime 版本:2.0.11888.0(测试版)无法连接到 cosmosDB
- windows - Windows Apache SSL 配置未加载页面
- java - 不同任务类型的锁存器
- jquery - 读取 DOM 中的所有类名,读取这些类的样式值并将它们内联添加到元素中?
- ms-access - 访问:使用一列中的表数据作为另一表中的字段名
- c++ - 标准::数组
与标准::数组 重载决议 - sql - 在子查询上使用“拥有”
- totp - TOTP:秒数吗?
- arrays - vba - 循环内的循环冻结excel