【发布时间】:2019-08-24 22:29:31
【问题描述】:
这是我第一次尝试使用 Flexbox,但遇到了一些问题。
我想创建一个可在桌面、平板电脑和类似这样的布局上运行的响应式布局:
我写了这段代码:
var screenType = 'mobile' // this variable return 'mobile' or 'tablet' or 'desktop'
.container {
display: flex;
flex-wrap: wrap;
flex-direction: row;
}
.big {
background-color: tomato;
width: 60%;
height: 100%;
}
.small {
background-color: green;
width: 40%;
height: 100%;
}
<div class="container">
<div class="big">big</div>
<div class="small">small</div>
</div>
如何使用变量类型来使用 Flex 创建不同的布局?
我想我必须更改width、height、flex-direction 但我不知道如何...
【问题讨论】:
-
"如何使用变量类型来使用 Flex 创建不同的布局?" - 别。请改用媒体查询。
-
@Quentin 你能解释一下吗?
标签: javascript css layout flexbox