为什么边框颜色没有变成半透明,并且有一圈白色的东西
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>background属性</title>
<style type="text/css">
/*此处写代码*/
*{margin:0;
padding:0;
}
div{width:800px;
height:400px;
padding:20px;
border:50px solid red;
background:url("http://img1.sycdn.imooc.com/climg//582c39c00001091605000150.jpg")no-repeat center center;
background-color: rgba(0, 0, 0, .5);
background-clip: border-box;
background-clip: padding-box;
background-clip: content-box;
text-align: center;
background-size: 90%;
}
span.div_border{position:absolute;
top:0;
left:0;
width:800px;
height:400px;
span.div_padding{position: absolute;
top:50px;
left:50px;
width:800px;
height: 400px;
}
</style>
</head>
<body>
<!-- 此处写代码 -->
<div>慕课网(IMOOC)国内最大的IT技能学习平台</div>
<span></span>
<span></span>
</body>
</html>这部分学的有点不太懂,请问边框如何设置成为半透明的颜色,另外不知道为什么边框有一道白色的,还请指点,十分感谢!!
32
收起
正在回答
2回答
边框颜色就用你背景色rgba的写法,0.5透明度,rgba(255,0,0,0.5)。白色是你20px的padding,因为background-clip你写了3个,最后一个内容区域覆盖了前面,padding就不在背景范围内了。
HTML5与CSS3实现动态网页 2018
- 参与学习 1887 人
- 提交作业 4643 份
- 解答问题 5760 个
有HTML和CSS基础,却不知道如何进阶?本路径带你通过系统学习,完成从“会做网页”到“做出好的动态网页”的蜕变,迈出成为前端工程师的第一步。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星