提问人:Rica Christine 提问时间:10/18/2023 最后编辑:tacoshyRica Christine 更新时间:10/18/2023 访问量:28
如何使用 HMTL 和 CSS 创建带有内容的箭头向上形状 div 层?每个向上箭头形状都是可悬停的,但只能悬停在箭头内
How to create a layer of arrow up shape div with content using HMTL and CSS? Each arrow up shape is hoverable but should only hover inside the arrow
答:
0赞
tacoshy
10/18/2023
#1
创建箭头不是使用伪元素,而是使用 。剪辑路径不会隐藏元素的某些部分,而是实际上将它们剪切掉。这意味着,“元素的不可见部分”实际上并不存在,因此不会识别它们:clip-path
:hover
.arrow {
background-color: red;
height: 70vh;
width: 60vh;
clip-path: polygon(50% 0, 100% 30vh, calc(100% - 10vh) 30vh, calc(100% - 10vh) 100%, 10vh 100%, 10vh 30vh, 0 30vh);
}
.arrow:hover {
background-color: blue;
}
.offset {
position: absolute;
top: 20vh;
background-color: pink;
}
<div class="arrow"></div>
<div class="arrow offset"></div>
评论
<>
Ctrl + M
clip-path