点击查看html编辑器说明文档

使用线性渐变来模拟长阴影edit icon

|
|
Fork(复制)
|
|
提交反馈
嵌入
设置
下载
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ...
展开
</head>
<body>
            
            <div></div>
        
</body>
SCSS
格式化
            
            body {
    background: linear-gradient(90deg, hsl(199, 98%, 50%), hsl(199, 98%, 38%));
    overflow: hidden;
}

div {
    position: relative;
    width: 30vmin;
    height: 30vmin;
    background: #fff;
    margin: 30vmin auto;
}

div::before,
div::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
}

div::before {
    transform-origin: 0 50%;
    transform: translate(100%, 0) skewY(45deg) scaleX(.6);
    background: linear-gradient(90deg, rgba(0, 0, 0, .3), transparent);
    animation: shadowMoveY 5s infinite linear alternate;
}

div::after {
    transform-origin: 0 0;
    transform: translate(0%, 100%) skewX(45deg) scaleY(.6);
    background: linear-gradient(180deg, rgba(0, 0, 0, .3), transparent);
    animation: shadowMoveX 5s infinite linear alternate;
}

@keyframes shadowMoveX {
    to {
        transform: translate(0%, 100%) skewX(50deg) scaleY(.6);
    }
}

@keyframes shadowMoveY {
    to {
        transform: translate(100%, 0) skewY(40deg) scaleX(.6);
    }
}
        
JS
格式化
            
            
        
预览
控制台