如何在窗口大小上使CSS网格更改布局?
CSS网格是否具有像材料UI网格必须根据布局尺寸更改的技巧?但是我想使用普通的CSS来做到
这一点,我现在有
.grid {
height: 100vh;
display: grid;
grid-template-columns: 200px 1fr;
grid-template-rows: 2fr 8fr 2fr;
grid-template-areas:
'header header'
'sidebar body'
'footer footer';
}
.header {
grid-area: header;
background-color: blue;
}
.sidebar {
grid-area: sidebar;
background-color: green;
}
.body {
grid-area: body;
background-color: red;
}
.footer {
grid-area: footer;
background-color: purple;
}
它成为此布局。当屏幕较小时,我希望它变成
header (2/14)
sidebar (2/14)
body (8/14)
footer (2/14)
Does the CSS grid have a trick like the material UI grid has to change based on layout size? but I wanna do it with regular CSS
I have this right now
.grid {
height: 100vh;
display: grid;
grid-template-columns: 200px 1fr;
grid-template-rows: 2fr 8fr 2fr;
grid-template-areas:
'header header'
'sidebar body'
'footer footer';
}
.header {
grid-area: header;
background-color: blue;
}
.sidebar {
grid-area: sidebar;
background-color: green;
}
.body {
grid-area: body;
background-color: red;
}
.footer {
grid-area: footer;
background-color: purple;
}
It becomes this layout. When the screen is smaller I want it to become
header (2/14)
sidebar (2/14)
body (8/14)
footer (2/14)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用媒体查询。就像材料UI和其他所有UI库的使用一样,
您也可以根据自己的愿意更改最大宽度
use media querys. Just as material ui and every other ui libraries use
You can change the max-width as you prefer