2017-06-17 68 views
-1

整个屏幕这是我的代码:如何使背景图像覆盖的移动

body { 
 
\t 
 
\t margin: 0px; /* Background Image Margin will be 0 */ 
 
    background-image: url('https://static.pexels.com/photos/17679/pexels-photo.jpg'); /* Background Image Linki */ 
 
    background-repeat: no-repeat; /* Background Image Will not repeat */ 
 
    background-attachment: fixed; /* Background Image will stay fixed */ 
 
    background-size: cover; /* This will make background image width 100% and height 100% */ 
 
\t 
 
\t 
 
}
<h1>Hello</h1>

这是工作完全正常。当我重新调整浏览器的大小或在谷歌浏览器中使用f12> mobile size时,它工作得很好。

但是,当我在真正的移动设备上使用它时,宽度是100%,高度也是100%。这意味着,该照片仅覆盖移动设备上60%的高度。

我使用此meta标签:

<meta name="viewport" content="width=device-width, initial-scale=1"> 

回答

-1

body { 
 
\t 
 
\t margin: 0px; 
 
    background-image: url('https://www.w3schools.com/css/img_fjords.jpg'); 
 
    background-repeat: no-repeat; 
 
    background-attachment: fixed; 
 
    background-size: cover; 
 
\t 
 
}
<h1>hi</h1>