我有一个 div,并且在其背景中应用了线性渐变。我已经使用了 :before 选择器。每当我将鼠标悬停在它上面时,div 的背景颜色就会消失。可能是什么问题。
这是代码
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background: #212727;
width: 100vw;
height: 100vh;
}
.container{
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.container .box{
position: relative;
width: 300px;
height: 400px;
background: linear-gradient(90deg,rgb(137, 85, 228) 50%,rgb(119, 62, 216)50%);
border-radius: 2px;
color: white;
text-align: left;
text-transform: capitalize;
padding: 30px 20px;
transition: all .4s linear;
}
.container .box::before{
content: "";
position: absolute;
top: -2px;
left: -2px;
width:304px ;
height:404px;
z-index: -1;
background: linear-gradient(45deg,rgb(195, 167, 243) ,rgb(190, 162, 237));
box-shadow:4px 2px 24px 1px rgb(181, 149, 237), -4px -2px 24px 1px rgb(186, 157, 235) ;
border-radius: 2px;
}
.box:hover{
transform: translateY(-7px);
}
<div class="container">
<div class="box">
<p></p>
<p></p>
</div>
</div>