我遇到了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>
答案 0 :(得分:5)
只需移动侧栏旁边的内容
即可
.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>