一、效果图
![]()
二、源码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS3背景图片属性的用法</title>
    <style>
        .clip-img {
            width: 130px;
            height: 130px;
            margin: 200px auto;
            background-image: url(bg.jpg);
            background-repeat: no-repeat;
            position: relative;
        }
        .clip-img::before,
        .clip-img::after {
            content: '';
            width: 100%;
            height: 100%;
            position: absolute;
            padding: 30px;
            /*通过box-sizing来设置宽度的计算方式 content部分为70px*/
            box-sizing: border-box;
        }
        .clip-img::before {
            background-color: #fff;
            /*确定背景区域为内容部分,不包含padding和border*/
            background-clip: content-box;
        }
        .clip-img::after {
            left: 20px;
            top: 30px;
            background-image: url(bg.jpg);
            background-clip: content-box;
            background-repeat: no-repeat;
            /*设置背景图的定位原点,默认为padding-box*/
            background-origin: padding-box;
        }
    </style>
</head>
<body>
<div class="clip-img"></div>
</body>
</html>