gpt4 book ai didi

html - CSS 网格不适合我

转载 作者:行者123 更新时间:2023-11-28 05:13:57 24 4
gpt4 key购买 nike

我对 display: grid 有疑问。我想要标题顶部和 33% 宽度的侧边栏列和 66% 的内容。我已经声明了 grid-area。你能帮帮我吗?

.head {
grid-area: head;
background: tomato;
}

.side {
grid-area: side;
background: purple;
}

.content {
grid-area: content;
background: orange;
}

body {
margin: 0;
}

* {
box-sizing: border-box;
}

.wrapper {
display: grid;
grid-gap: 10px;
grid-template-areas:
"head head head"
"side" "content content"
}

.box {
padding: 20px;
height: 100px;
}
<div class="wrapper">
<div class="box head">
</div>
<div class="box side">
</div>
<div class="box content">
</div>
</div>

最佳答案

只需将侧边栏旁边的内容移动

.head {
grid-area: head;
background: tomato;
}

.side {
grid-area: side;
background: purple;
}

.content {
grid-area: content;
background: orange;
}

body {
margin: 0;
}

* {
box-sizing: border-box;
}

.wrapper {
display: grid;
grid-gap: 10px;
grid-template-areas:
"head head head"
"side content content"
}

.box {
padding: 20px;
height: 100px;
}
<div class="wrapper">
<div class="box head">
</div>
<div class="box side">
</div>
<div class="box content">
</div>
</div>

关于html - CSS 网格不适合我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50015567/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com