请问怎么样才能让背景图片显示全部,背景图片左边的部分没有了

请问怎么样才能让背景图片显示全部,背景图片左边的部分没有了

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
<title>mooc</title>
<style>
   *{
    margin:0;
    padding:0;
   }
   .background{
       width:100%;
            height:4096px;
    background:url(http://img1.sycdn.imooc.com/climg//59c9f7ce0001839219034033.png) center top no-repeat;
   }
   .left{width:224px;
    height:364px;
    position:fixed;
    top:50%;
    margin-top:-182px;
    left:0;

    background: url(http://img1.sycdn.imooc.com/climg//5a3383c70001f1b702240364.png) center top no-repeat;
   }
   .right{width:224px;
    height:364px;
    position:fixed;
    top:50%;
    margin-top:-182px;
    right:0;
    background: url(http://img1.sycdn.imooc.com/climg//5a3383d00001a3dd02240364.png) center top no-repeat;
   }
</style>
</head>
<body>
    <div class="background">
      <div class="left">
          
      </div>
      <div class="right">
          
      </div>      
    </div>

</body>
</html>


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕糖 2018-03-20 17:25:50

你好,若是html中引入的图片的话,可以设置宽度,背景图片的话,可以尝试设置background-size:cover;属性。

祝学习愉快~

慕雪殇 2018-03-20 11:01:36

width 设置为图片宽度

  • 提问者 小六卡脸 #1
    但是这样网页就会变宽,能不能让图片正好显示的是视口的宽度。
    2018-03-20 15:16:18
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师