我想将 inner-section 和 sidebar 设置为某个最小高度,然后它们应该随着 main
标签垂直展开。
HTML代码:
<body>
<header></header>
<main>
<section>
<section class="innersection">
some content
</section>
<aside class="sidebar">
snas
</aside>
</section>
</main>
<footer></footer>
</body>
CSS 代码:
main{
width: 100%;
min-height: 800px;
}
.innersection{
float:left;
width:94%;
display:inline;
}
.sidebar{
float:right;
width:5%;
display:inline;
}
我试过了,还是不行。对于内部部分和侧边栏,main
标签的高度不会增加。我附上了页面的图片 .
最佳答案
希望我理解正确,您希望 .innersection
和 .sidebar
具有相同的高度,并且都采用其父级的高度?
如果是这样,您可以将 main > section
显示为表格,并将两个子项显示为表格单元格。
main{
width: 100%;
min-height: 800px;
}
main > section {
width: 100%;
display: table;
}
.innersection{
width:94%;
height: 800px;
display:table-cell;
}
.sidebar{
width:5%;
display: table-cell;
}
关于html - 设置 section 和 aside 以使用 main 标签自动展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25867410/