2 个回答

第三个拖拽
3GL~8NLC_D@1$QC2)19WYF0.png

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            position: relative;
            margin: 0 1em 1em 0;
            display: inline-block;
            border: 1px solid red;
        }
        .box .mask {
            top: 0;
            left: 0;
            right: 0;
            position: absolute;
            background-color: rgba(0, 0, 0, 0.3);
        }
        .box1 .mask {
            height: 50px;
            border-radius: 0 0 100% 100%;
        }
        .box2 .mask {
            height: 10px;
            border-radius: 0 0 10% 100%;
        }
    </style>
</head>
<body>
    
    <div class="box box1">
        <div class="mask"></div>
    </div>
    <div class="box box2">
        <div class="mask"></div>
    </div>
    <div class="box box3">
        <div class="mask"></div>
    </div>

    <script>
        const box = document.getElementsByClassName('box3')[0]
        let y = 0
        box.addEventListener('mousedown', ({ offsetY }) => {
            box.movable = true
            y = offsetY
        })
        box.addEventListener('mouseup', ({ offsetY }) => {
            box.movable = false
            y = 0
        })
        box.addEventListener('mousemove', ({ offsetX, offsetY }) => {
            if(box.movable) {
                const w = parseFloat(getComputedStyle(box).width)
                
                setLRH(
                    Math.round(offsetX / w * 100),
                    Math.round(100 - offsetX / w * 100),
                    offsetY - y
                )
            }
        })
        function setLRH(l, r, h) {
            const mask = box.getElementsByClassName('mask')[0]
            mask.style.borderRadius = `0 0 ${r}% ${l}%`
            mask.style.height = `${h}px`
        }
    </script>
</body>
</html>

你说的是那个半圆形的阴影吗?安卓手机列表滑动都这样的,应该是material design的实现吧。

不过我百度下没有大佬做这个的css模拟
宣传栏