【发布时间】:2017-10-28 03:31:50
【问题描述】:
我正在尝试在 CSS3 Flex 中实现简单干净的响应式布局,其中:
A) 在桌面模式下,正文包含三个并排的垂直元素“全部在一行中”,并且;
B)另一种垂直方向的移动版本模式,其中主体包含作为彼此顶部的行的元素,“全部在一个列中”。
但我的代码在某处被破坏,因为在将窗口大小调整为缩小垂直方向时,我没有看到移动版本启动。我错过了什么?
*{
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
display: flex;
min-height: 100vh;
flex-direction: row;
flex: 1;
background: yellow;
}
main {
flex: 2;
background: tomato;
}
nav {
flex: 1;
background: tan;
}
aside {
flex:1;
background: thistle;
}
/* FOR MOBILE PHONES */
@media only screen and (orientation: vertical) and (max-width: 768px) {
body{
flex-direction: column;
}
main {
background: crimson; /* test to see if mobile mode is activated */
}
}
<body>
<main>content</main>
<nav>nav</nav>
<aside>aside</aside>
</body>
【问题讨论】:
标签: css mobile responsive-design flexbox desktop