【发布时间】:2017-11-07 06:12:23
【问题描述】:
我正在开发一个简单的响应式布局,但遇到了 html 元素大小异常的问题。当屏幕尺寸大于 1080px 时一切正常,但每次我调整屏幕大小或在移动设备上加载页面时,html 元素都会变得小于屏幕宽度。
Here you can see what I am talking about.
And here you can see the html width
我尝试过的: (我正在使用thiscss 重置)
1) 将 html 和 body 的边距、内边距设置为 0,并将它们的宽度设置为 100%;
2) 设置 box-sizing 属性为border-box;
3) 添加:
html, body{width: 100%; padding: 0; margin: 0;}
4)我也试过写一些js代码来设置resize时body的宽度,但是我不擅长js所以没有帮助..
5) 字体大小更改也无济于事。
可能有一个简单的解决方案,但是我越是尝试修复它,我就越感到困惑,所以我希望有人能帮助我。
我是新来的,所以请多给我一点耐心:)。
这是正文 css:
body{
background-image: url(gwiazdy.png) !important;
background-position: center;
background-attachment: fixed;
background-size: cover;
background-color: #000;
width: 100% !important;
font-size: 20px !important;
padding: 2% 0 !important;
margin: 0 !important;
font-family: 'Bellefair', serif !important;
color: #ccc !important;
min-width: 329px !important;}
@media screen and (max-width: 752px) {
.content{
width: 100% !important;
}
body{
padding: 0 !important;
padding-bottom: 15 !important;
}
}
如果还不够,可以click here看我的布局,也可以看整个css和html。
【问题讨论】:
-
你有一个比身体大的元素
-
发布与此问题相关的 HTML
-
这是你的
.about_text -
哇,现在可以了。感谢您的快速回答:)
-
您的 html 标记不正确,您不能在
doctype中包含body