老师检查一下,如果设置的宽高与图片大小不一样会怎样呢?如何设置图片的宽高合适?

来源:4-3 编程练习

慕九州8176055

2019-09-23 17:12:38

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>广告栏定位</title>

<style type="text/css">

*{

margin: 0;

padding: 0;

}

html,body{

width: 100%;

height: 100%;

}

.all{

width: 100%;

height: 4000px;

background: url("http://climg.mukewang.com/59c9f7ce0001839219034033.png") center top no-repeat;

}

.one{

width: 220px;

height: 300px;

position: fixed;

right:0;

top:50%;

margin-top:-150px;

}

.two{

width: 220px;

height: 300px;

position: fixed;

left:0;

top:50%;

margin-top:-150px;

}

</style>



</head>

<body>

<div class="all">

<div class="one"><img src="http://climg.mukewang.com/5a3383c70001f1b702240364.png"></div>

<div class="two"><img src="http://climg.mukewang.com/5a3383d00001a3dd02240364.png"></div>

</div>

</body>

</html>


写回答

1回答

好帮手慕码

2019-09-23

同学你好!

代码效果没有实现。建议外层div和内部img设置为一样的宽高,避免压缩:

例如:

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

如果帮到了你,欢迎采纳,祝学习愉快~

0

0 学习 · 40143 问题

查看课程