老师 帮忙检查一下代码

来源:4-3 编程练习

lcy_18

2020-03-28 14:32:13

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8" />
  <title></title>
  <style type="text/css">
   *{
    padding: 0;
    margin: 0;
   }
   .content{
    width: 100%;
    height: 4050px;
    background: url("http://climg.mukewang.com/59c9f7ce0001839219034033.png") center top no-repeat;
   }
   
   .left_img img{
    width: 220px;
       height: 270px;
       position: fixed;
       left: 0;
       top: 50%;
       margin-top: -110px;
   }
   
   .right_img img{
    width: 220px;
    height:270px;
    position: fixed;
    right: 0;
    top: 50%;
    margin-top: -110px;
   }
  </style>
 </head>
 <body>
  <div class="content">
   <div class="left_img"><img src="http://climg.mukewang.com/5a3383d00001a3dd02240364.png" /></div>
   <div class="right_img"><img src="http://climg.mukewang.com/5a3383c70001f1b702240364.png"/></div>
  </div>
 </body>
</html>

写回答

4回答

好帮手慕码

2020-03-29

同学你好,解答如下:

(1)查看原始图可以在控制台中查看(按f12):

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

(2)这里设置auto就相当于是高度为0,没有内容去撑开,所以图显示不出来:

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

祝学习愉快~

0

lcy_18

提问者

2020-03-29

在打代码时还出现了一个问题,就是为什么当我把背景图片height设为auto时图片出不来

0

lcy_18

提问者

2020-03-29

要怎么看图片的原始大小?

0

好帮手慕久久

2020-03-28

同学你好,问题总结如下:

1. 垂直方向居中,margin-top值计算错误,参考如下

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

2. 需要优化的问题如下:

图片的原始宽高是224*364px, 同学设置成220*270px后图片会变形,建议使用原始图片高度,另外样式可以简化书写,修改如下:

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

如果我的回答帮助了你,欢迎采纳,祝学习愉快~

0

0 学习 · 40143 问题

查看课程