人生与戏

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>求背景图片左边到#box盒子左边外框侧的距离</title>

    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        #box{
            width: 100px;
            height: 200px;
            background: pink;
            padding: 100px;
            border: 80px solid blue;
            background-image: url("img/1.png");
            background-repeat: no-repeat;
            background-origin: content-box;/* 背景图片起始源的位置 */
            background-position: -50px 0; /* 左右 上下*/
           /*  background-position 和margin (上下 ; 左右) 等不一样*/
        }

        /*答案:130px*/
    </style>
</head>
<body>
<div id="box"></div>
</body>
</html>

 

posted on 2018-10-29 10:40  人生与戏  阅读(140)  评论(0编辑  收藏  举报