有没有人有类似的经历并有解决办法?
我使用下面的 CSS 在手机上显示背景图片,当然我声明了
我无法根据屏幕的高度和宽度显示图像,如果我删除“background-attachment: fixed”,则图像会根据屏幕的高度和宽度调整大小,但图像会根据屏幕的长度居中网页内容而不是屏幕。
谁有更好的解决方案?
#home {
background: url('../images/hkfmpt_trans.png');
background-repeat:no-repeat;
background-position:center;
background-attachment: fixed;
background-size: contain;
}
最佳答案
试试这个
html {
background: url('../images/hkfmpt_trans.png') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
关于html - 修复了屏幕比例为 100% 的背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24140113/