麻烦老师看下是否正确,谢谢。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>background-size</title>
<style type="text/css">
a{text-decoration:none;}
ul{list-style:none;}
div{
background-image:url("http://img1.sycdn.imooc.com/climg//582c37e50001b08102000065.jpg");
width:100px;height:100px;
display:none;border:2px solid red;
background-repeat:no-repeat;
}
/*补充代码*/
.length:hover div,.percent:hover div,.cover:hover div,.contain:hover div{ display:block;}
.length div{
background-size: 100px 100px;
}
.percent div{
background-size: 50% 50%;
}
.cover div{
background-size: cover;
}
.content div{
background-size: contain;
}
</style>
</head>
<body>
<h2>background-size不同属性值不同效果</h2>
<ul>
<li class="length">
<h3><a href="">100px 100px</a></h3>
<div></div>
</li>
<li class="percent">
<h3><a href="">50% 50%</a></h3>
<div></div>
</li>
<li class="cover">
<h3><a href="">cover</a></h3>
<div></div>
</li>
<li class="contain">
<h3><a href="">contain</a></h3>
<div></div>
</li>
</ul>
</body>
</html>
正在回答
你好同学,效果实现正确,很棒。继续加油,祝学习愉快!
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星