【问题标题】:Differentiate between mobile and desktop区分移动端和桌面端
【发布时间】:2021-03-19 00:27:46
【问题描述】:

我有一个组件应该根据设备更改布局。

在移动设备上它应该堆叠内容,例如:

https://codesandbox.io/s/material-demo-forked-ktoee?file=/demo.tsx

在桌面上,内容应该像这样放置:

https://codesandbox.io/s/ykyng?file=/demo.tsx

如何用 flex 解决?

【问题讨论】:

    标签: css reactjs material-ui jss


    【解决方案1】:

    这在没有媒体查询的情况下实现了相同的效果。 flexbox 容器设置为用

    换行到多行

    flex-wrap: 换行;

    文本设置为使用扩展至可用空间

    弹性增长:1;

    并且最小宽度为 400 像素

    弹性基础:400px;

    https://codesandbox.io/s/material-demo-forked-f2pc8

    【讨论】:

    • 在移动设备上,Live From Space 文字应位于图片上方。
    • 有可能吗?
    • 让我们使用 flex-wrap: wrap-reverse 然后
    • 现在怎么样?是不是更好看?
    • 我明白了,这可能需要一些时间,如果没有人回答,我稍后再回复
    猜你喜欢
    • 2018-10-07
    • 2022-05-21
    • 1970-01-01
    • 2021-06-24
    • 2018-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多