麻烦老师检查一下
来源:2-7 编程练习
老二次
2020-02-13 15:17:48
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>background-origin</title>
<style type="text/css">
div {
width: 300px;
height: 150px;
border: 10px solid rgba(0,0,255,0.2);
padding: 10px;
background-image: url(http://img1.sycdn.imooc.com//climg/582c342b0001fd6507000210.jpg);
background-clip: padding-box;
}
div:hover {
background-clip: content-box;
background: url(http://img1.sycdn.imooc.com//climg/582c34220001091605000150.jpg) no-repeat 10px 10px;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
1回答
同学你好,鼠标悬停在元素上时,背景图片的起点从内容区域的左上角开始,并且背景图片显示范围从边框开始。没有实现,建议修改如下:
另,可以把div的高度设置小一点,效果更佳符合效果图:
如果我的回答帮到了你,欢迎采纳,祝学习愉快~
相似问题