有迹象表明,来到我的脑海三种解决方案:
- 使用断点
- 使用最小宽度&宽度组合
- 流体布局
1.断点: 所以,如果文档宽度为i,您希望将主容器元素的宽度设置为60% s大于768px(例如,最大移动分辨率)。该代码将是:
.container {
margin: 0 auto; // horizontally centering element
background-color: pink; // just to see where the element is
}
// targeting mobile screen size:
@media only screen
and (max-width: 768px)
and (-webkit-min-device-pixel-ratio: 2) {
width: calc(100% - 30px);
}
// targeting larger screens
@media only screen
and (min-width: 769px)
and (-webkit-min-device-pixel-ratio: 2) {
width: 60vw;
}
2.最小宽度:也许是一个简单的解决方案,但不是说好,如果你也有视台,在这里你只需要确定的是什么风格等元素的子元素是最小的container
宽度,看起来没问题,并将其设置为min-width
属性的值。
.container {
margin: 0 auto; // horizontally centering element
background-color: pink; // just to see where the element is
width: 60vw;
min-width: 320px;
}
也许第三,最先进的技术,可以帮助你,如果没有以上就可以了,这是Fluid technique,在一个细节在这个碎杂志的文章,这实际上是在排版最有趣的解释因为最常见的布局技术是我首先解释的技术。
希望我设法提供帮助。
来源
2016-12-27 14:00:28
Moo
显示一些代码!学习创建[mcve] –