[英]How to make a background image responsive and show on mobile devices
我設法將背景圖片顯示在台式設備上並做出響應,但是當我在移動設備上查看網站時,背景圖片沒有顯示。
這是我到目前為止的代碼:
#intro{
background: url(../img/trees.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/trees.png', sizingMethod='scale');
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../img/trees.png', sizingMethod='scale')";
min-height: 100%;
}
將此插入您的頭部:
<meta name="viewport" content="width=device-width, initial-scale=1">
將background-size to 100vh
的高度100vw
為100vw
,將寬度100vw
為100vw
body{
width: 100%;
height: 100%;
margin: 0px;
background: url(../image/background.jpg) no-repeat fixed top center;
background-size: cover;
}
使用#intro{ background-size:100% 100%;}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.