首页 > 技术文章 > css 一张背景图铺满整个页面 html

maibao666 2021-02-08 12:57 原文

1.body{

backgroung:ure(./ing/picture.png)   

backgroung-size:100% 100%;

background-repeart:no-repeart;

background-attachment:fixed;

overflow:auto;

}

vue中

  1. <div id="home"></div>
    css: <style>
    #home {
  2.  
    width: 100%;
  3.  
    height: 100%;
  4.  
    background: url("~@/images/home/h_bg.png") center center no-repeat;
  5.  
    background-size: 100% 100%;
  6.  
    position: fixed;//固定定位
  7.  
    }
  8.  

背景全屏,内容完全显示且可滚动查看  

 

  1.  
    <div id="home"></div>
  2.  
     
  3.  
    css:
  4.  
    <style>
  5.  
    #home {
  6.  
    width: 100%;
  7.  
    height: 100%;
  8.  
    background: url("~@/images/home/h_bg.png") center center no-repeat;
  9.  
    background-size: 100% 100%;
  10.  
    position:absolute;//绝对定位
  11.  
    }
  12.  
    </style>

 

推荐阅读