l老师,我开始css是写的div的,能解释下为什么是写img的样式呢
来源:7-2 编程练习
Hategreen
2020-04-07 00:02:32
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.img1{
width:100%;
height:100%;
}
.img2{
width:200px;
height:300px;
position:fixed;
top:50%;
}
.img3{
width:200px;
height:300px;
position:fixed;
top:50%;
right:0px;
}
</style>
</head>
<body>
<div class="div1">
<img class="img1" src="http://climg.mukewang.com/59c9f7ce0001839219034033.png" alt="#">
</div>
<div class="div2">
<img class="img2" src="http://climg.mukewang.com/5a3383d00001a3dd02240364.png" alt="#">
</div>
<div class="div3">
<img class="img3" src="http://climg.mukewang.com/5a3383c70001f1b702240364.png" alt="#">
</div>
</body>
</html>
1回答
你好,css标签定位方法不是唯一的,如:
.img2{
width:200px;
height:300px;
position:fixed;
top:50%;
}
和
.div2 img{
width:200px;
height:300px;
position:fixed;
top:50%;
}
效果是相同的,只要能找到该标签即可,如果解决您的问题请采纳,祝学习愉快!
相似问题