【发布时间】:2017-10-14 19:10:36
【问题描述】:
我想用flexbox实现关注Layout:
您可以在图片中看到两个方向。左侧为纵向视图,右侧为横向视图。
前提是我想让我的html尽可能短(如果可能的话)。
有没有办法用 flex 做到这一点?
在纵向视图中,一切正常,因为它只是一列。
现在我被困在横向。
导航应该在屏幕右侧,其他内容在左侧。
header, footer, main, nav {
margin: 5px;
padding: 5px;
border-radius: 5px;
min-height: 120px;
border: 1px solid #eebb55;
background: #ffeebb;
}
section {
display: flex;
flex-direction: column;
}
@media only screen and (orientation: landscape) {
/* no clue */
}
<section>
<header>header</header>
<main>content</main>
<nav>navigation</nav>
<footer>footer</footer>
</section>
非常感谢您的宝贵时间!
【问题讨论】:
-
好的,您的解决方案可以很好地解决这个问题。但是我现在需要为双方单独滚动,我认为使用这样的 html 语法是不可能的。我必须操作 DOM。取出导航并将部分和导航高度设置为 100vh 并溢出以滚动。 Flex 和 Grid 不适合我的问题。我有点失望。但是非常感谢@Michael_B ;)