gpt4 book ai didi

html - 曲线形状的 Div 边框

转载 作者:太空宇宙 更新时间:2023-11-04 06:54:53 25 4
gpt4 key购买 nike

我试图在凸形中实现 div 边框,并且在悬停时它应该是正常的方形。我在底部添加了我想在顶部添加的内容,我之前尝试使用但无法实现结果。任何人都可以帮助我下面是我到目前为止所做的代码。任何帮助将不胜感激 enter image description here

* {
box-sizing: border-box;
}
.services {
position: relative;
width: 500px;
height: 420px;
margin: 100px;
background-color: #cccccc;
transition: all 0.2s ease;
animation: down-bump 0.4s ease;
}
.services:before {

}
.serv_section {
top: 83%;
position: relative;
overflow: hidden;
padding: 50px 0 0;
}

.serv_inner {
position: relative;
background: #fff;
height: 25px;
}
.serv_inner:after {
box-shadow: 0 0 0 80px #fff;
border-radius: 100%;
position: absolute;
height: 150px;
content: '';
right: -20%;
left: -20%;
top: -150px;
transition: all 0.4s ease-in-out;
}

.services:hover .serv_inner:after {
top: -120px;
}

.serv_inner:before {
/* box-shadow: 0 0 0 80px #fff;
border-radius: 100%;
position: absolute;
height: 150px;
content: '';
right: -20%;
left: -20%;
top: 130px;
transition: all 0.4s ease-in-out; */
}

span.image_caption {
position: absolute;
color: red;
padding: 10px 20px;
font-size: 30px;
z-index: 10;
animation-duration: 2.5s;
animation-fill-mode: both;
}
span.image_caption p {
font-size: 32px;
font-weight: 900;
font-family: 'Dancing Script', cursive;
color: cadetblue;
}
	
<div class='services'>
<div class="serv_section">
<div class="serv_inner">


</div>
</div>
</div>

最佳答案

你可以使用 before 和 after 元素来制作曲线,悬停时隐藏元素后面的伪元素并像这样删除曲线:

.services {
position: relative;
width: 100px;
height: 60px;
margin: 100px;
background-color: #cccccc;
z-index: 0;
}
.services:hover:before{
top: 0px;
border-radius: 0;
}
.services:hover:after{
bottom: 0px;
border-radius: 0;
}
.services:before, .services:after{
content: ' ';
position: absolute;
width: 100%;
height: 40px;
background-color: #cccccc;
border-radius: 50%;
z-index: -1;
transition: all .4s;
}
.services:before {
top: -20px;
}
.services:after {
bottom: -20px;
}
<div class='services'>

</div>

关于html - 曲线形状的 Div 边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52550927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com