html - In a flexbox, how can I arrange 2 items in a row and 2 items in a column? -
i trying move towards flexboxes , stumbled across first problem. have created wrapper, logo fits on left , message area takes same height, on far right. in middle 2 stacked flexboxes, top being news ticker , bottom being menu. problem having news ticker not @ top, , menu not underneath it. driving me nuts. can me please.
body { color: #cf6; margin: 0 auto; font-size: 1.0em; max-width: 1280px; overflow-y: scroll; text-transform: uppercase; font-family: "tahoma", verdana, sans-serif; background: black; } #head_main { height: 112px; margin-bottom: -112px; border: 2px solid #444; } #head_wrap { width: 92%; display: flex; margin: 0 auto; xmin-width: 40em; max-width: 84em; flex-flow: row wrap; border: 1px solid orange; } #head_logo { top: 0; left: 0; order: 1; width: 77px; height: 112px; border: 1px solid red; } #head_info { top: 0; flex:1; order: 2; color: #0ff; height: 45px; display: block; min-width: 12em; font: normal 125%/45px arial, helvetica, sans-serif; } #head_news { font-weight: 700; padding-right: 5px; border: 1px solid green; } #head_note { top: 0; order: 3; width: 77px; height: 112px; border: 1px solid cyan; } #head_menu { order: 4; flex: auto; margin: 0 auto; display: flex; align-items: center; justify-content: center; border: 1px solid blue; }
<body> <!-- header --> <header id="head_main"> <section id="head_wrap"> <article id="head_logo"> logo </article> <article id="head_info"> <ul id="head_news"> <li>news ticker</li> </ul> </article> <article id="head_note"> msgs </article> <article id="head_menu"> <nav> <ul> menu </ul> </nav> </article> </section> </header> <!-- body --> <!-- footer --> </body>
the problem having news ticker not @ top, , menu not underneath it.
the news ticker ul
has default top margin. that's why it's pushing away top border. close gap apply margin-top: 0
#head_news
rule.
the menu not underneath news ticker because flex-direction
property set row
. have set in head_wrap
id shorthand declaration flex-flow: row wrap
, defines flex-direction
, flex-wrap
properties. row
value aligns flexbox children (technically known "flex items") in row.
i have created wrapper, logo fits on left , message area takes same height, on far right. in middle 2 stacked flexboxes, top being news ticker , bottom being menu.
to stack news ticker , menu in column – between 2 other flex items – should wrap both in flex container , set flex-direction:
column
.
html
<div id="ticker-menu-block"> <article id="head_info"> <ul id="head_news"> <li>news ticker</li> </ul> </article> <article id="head_menu"> <nav> <ul> menu </ul> </nav> </article> </div>
css
.ticker-menu-block { display: flex; flex-direction: column; } #head_news { font-weight: 700; padding-right: 5px; border: 1px solid green; margin-top: 0; }
note: don't need order
property make work.
hope helps. if have questions post comment below.
Comments
Post a Comment