css3中的背景图片问题

来源:2-7 编程练习

weixin_慕的地5241954

2019-08-23 23:02:00

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>background-origin</title>
    </head>
    <style type="text/css">
        div{
            margin: 0 auto;
            width: 300px;
            height: 100px;
            border: 10px rgba(0, 0, 255,0.2) solid;
            padding: 10px;
            background: url(http://climg.mukewang.com/582c342b0001fd6507000210.jpg) no-repeat;
            background-clip: content-box;
        }
    </style> 
    <body>
        <div></div>
    </body>
</html>

为什么上和左边框没有被背景图片覆盖?

写回答

3回答

樱桃小胖子

2019-08-24

同学如果想要实现边框覆盖图片,则需要设置如下:

http://img.mukewang.com/climg/5d60a9ac0001f0a218130710.jpg

希望可以帮到你!

0

樱桃小胖子

2019-08-24

“weixin_慕的地5241954”同学给出的原因和解决办法,同学可以参考哦,掌声鼓励一下“weixin_慕的地5241954”同学,棒棒哒!

0
heixin_慕的地5241954
h 我把background-clip: content-box;换成background-clip: border-box;后还是没有覆盖上和左边框背景图片?
h019-08-24
共1条回复

weixin_慕的地5241954

提问者

2019-08-23

background-clip: content-box;这里写错了,是background-clip: border-box;

0

0 学习 · 40143 问题

查看课程