css3-smooth over glass effect

css attributes

  • box-shadow: x, y axis offset, blur radius, diffusion radius, color; if multiple shadow rules are used, use commas to separate
  • linear-gradient: The function is used to create a picture with multiple color gradients. The first attribute can be to left(right) top(bottom) or angle. The angle is calculated from the vertical direction of the Y axis, clockwise
  • Use css 2D transformation, rotation and translation, to make the effect of smooth glass

effectInsert picture description here

Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
    <div>
        <h1>Hello World</h1>
    </div>
</body>
</html>
*{
    
    
    margin: 0;
    padding: 0;
}

body{
    
    
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

div{
    
    
    height: 150px;
    width: 250px;
    background-image: linear-gradient(to right, rgb(238, 118, 118), rgb(250, 101, 101));
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* 制作白色的光 */
div::after{
    
    
    content: "";
    width: 500px;
    height: 30px;
    position: absolute;
    left: 0;
    top: 30px;
    background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(238, 234, 234, 0.568), rgba(255, 255, 255, 0));
    transform: rotate(-45deg) translateY(-180px);
    transition: all .6s;
}

div:hover{
    
    
    box-shadow: 0px 5px 5px rgb(139, 137, 137);
}

div:hover::after{
    
    
    transform: rotate(-45deg) translateY(50px);
}
h1{
    
    
    line-height: 150px;
    text-align: center;
    color: #ffffff;
}

Guess you like

Origin blog.csdn.net/weixin_42100456/article/details/111939174