我使用这样的 css 来设置响应式背景。当我在手机上看到它时,如果页面上出现很多内容,背景会越来越大。避免缩放背景的正确方法是什么?谢谢
body {
background: url('someimage.jpg') no-repeat center center fixed;
background-size: cover;
}
最佳答案
像这样的视口(viewport)元标记可能会有所帮助(在您的 html 顶部):
<meta name="viewport" content="width=device-width, initial-scale=1">
这将确保在移动屏幕上,内容不会像在大屏幕上那样显示,并且 body 元素的宽度只会与屏幕一样宽。
关于html - 当出现更多内容时,css 响应式背景会缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38316288/