body {
max-width: 1000px !important;
margin-right: 5%;
margin-left: 5%;
height: 100%;
}
尝试按比例居中我的内容,同时将最大宽度保持在 1000px 似乎不起作用......有解决这个问题的方法吗?保持该元素 5% 的利润非常重要。
它将我的所有内容向左对齐..
最佳答案
如果您必须将页面内容居中,且分辨率低于 1000 像素,左右各留有 5% 的边距,您可以使用以下代码:
.container{
width:90%;
max-width:1000px;
margin:0 auto;
background-color: red;
height:500px;
}
<body>
<div class="container"></div>
</body>
超过 1000 像素的内容结果集中在您的页面中。
关于html - 以最大宽度和侧边距%居中内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43798847/