怎么在梯形上面添加背景图

帮帮忙,我想问一下怎么样用css样式在梯形上面放背景图,我用background-image不好使

img

img

你写的这种方式好像不太容易实现,以下是另一种方式,可以参考下。

img

<!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">
    <style>
        .container {
            width: 420px;
            height: 300px;
            clip-path: polygon(0 0, 100% 0, 70% 100%, 0 100%);
            background-size: 100% 100%;
            background-image: url("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsy0.img.pcpop.com%2Fcopy%2Fucb%2F3%2F3325%2F3325739%2F3%2F3325%2F3325739.png&refer=http%3A%2F%2Fsy0.img.pcpop.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651681014&t=c7852f9f77c660da54e256c0861f0982");
        }
    </style>
</head>

<body>
    <div class="container"> </div>
</body>

</html>