css - 如何在自定义形状周围添加类似路径的边框
问题描述
我需要像附件那样做图像。我用里面的图像做了多边形,但我不能添加蓝色的鸟。我对带有伪类的多边形使用剪辑路径。如何添加蓝色倾斜边框?
.clip-each-blue {
width: 100px;
height: 90px;
position: relative;
}
.clip-each-blue:after {
content: "";
position: absolute;
background: #fff;
}
.clip-each-blue,
.clip-each-blue:after {
-webkit-clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
background: #4850be;
}
.border-style-thin {
background-color: #4850be;
}
.content-feature-image {
display: block;
outline: 0;
}
.content-feature-image img {
display: block;
width: 50px;
height: 50px;
margin: 0 auto;
position: relative;
top: 20px;
z-index: 1;
transform: rotate(-90deg);
}
.border-style-thin:after {
top: 1px;
left: 1px;
right: 1px;
bottom: 1px;
}
<section id="polygon">
<div class="clip-wrap">
<div class="clip-each-blue-border">
<div class="clip-each-blue">
<a href="#" class="content-feature-image"><img src="images/section/section_2_icon_1.png" alt="" /></a>
</div>
</div>
</div>
解决方案
一种方法如下:
.clip-each-blue {
width: 100px;
height: 90px;
position: relative;
}
.clip-each-blue:after {
content: "";
position: absolute;
background: #fff;
}
.clip-each-blue,
.clip-each-blue:after {
-webkit-clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
transform: rotate(90deg); /* Rotate polygon to match desired output. */
background: #4850be;
}
.border-style-thin {
background-color: #4850be;
}
.content-feature-image {
display: block;
outline: 0;
}
.content-feature-image img {
display: block;
width: 50px;
height: 50px;
margin: 0 auto;
position: relative;
top: 20px;
z-index: 1;
transform: rotate(-90deg);
}
.border-style-thin:after {
top: 1px;
left: 1px;
right: 1px;
bottom: 1px;
}
/* New stuff. */
.clip-each-blue-border {
position: absolute;
left: 25px;
}
.clip-border {
border: 4px solid #4850be;
width: 140px;
height: 140px;
z-index: -1;
position: absolute;
transform: rotateX(60deg) rotateY(0deg) rotateZ(-45deg);
}
.clip-wrap {
position: relative;
}
<section id="polygon">
<div class="clip-wrap">
<div class="clip-each-blue-border">
<div class="clip-each-blue">
<a href="#" class="content-feature-image"><img src="images/section/section_2_icon_1.png" alt="" /></a>
</div>
</div>
<!-- Insert div to transform to isometric frame. -->
<div class="clip-border"></div>
</div>
</section>
推荐阅读
- python - python pandas将总和列转换为总和列
- android - 输入类型 = 注册号
- angular - 角度数组问题
- python - 尝试使用 selenium 运行脚本时出现错误
- asp.net-mvc - 在 IIS 上部署后,MVC url 路由不起作用
- react-native - 安装 ReactNative CLI 时出现 NPM 安装错误
- xaml - Xamarin 形成 Carrousel 并异步拍照
- c# - Selenium 获取属性/CSS/属性
- c++ - 每种数据类型都在数组中保留一个内存或地址,但是为什么逗号(,)不在数组中保留它的内存
- c++ - Meyers Singleton:静态关键字混淆