【やりたいこと】
htmlのレイアウト(2カラム)をflexを利用して作りたい。
・header,footerは横幅いっぱいに表示
・footerはsticky footerになるように設定
・main-wrapをmax-width:1000pxで表示
・main,asideを画面幅600px以上の時、2カラムで表示
現在のコード
html
1<header>header</header> 2 3<div class="main-wrap"> 4 <main> 5 <h2>test</h2> 6 <p>test test test test test test test test</p> 7 </main> 8 <aside id="side"> 9 <h2>test</h2> 10 <p>test test test test test test test test</p> 11 </aside> 12</div> 13 14<footer><small>footer</small></footer>
css
1 2body { 3 font-family: font-family: 'メイリオ','Hiragino Kaku Gothic Pro',sans-serif; 4 display: flex; 5 flex-direction: column; 6 min-height: 100vh; 7 margin: 0; 8} 9header { 10 background: #aaa; 11 padding: 15px; 12} 13.main-wrap { 14 flex: 1; 15 padding: 20px 16} 17main { 18 background: #ff5500; 19 padding: 0px; 20} 21aside { 22 background: #eee; 23 padding: 15px; 24} 25footer { 26 background: #ffa; 27 padding: 15px; 28} 29 30@media (min-width: 600px) { 31 .main-wrap { 32 display: flex; 33 max-width: 1000px; 34 margin-left: auto; 35 margin-right: auto; 36 } 37 main { 38 background: #ccc; 39 flex:4; 40 } 41 aside { 42 background: #eee; 43 flex:1; 44 } 45 46}
上記コードの場合、
・header,footerは横幅いっぱいに表示
・footerはsticky footerになるように設定
・main,asideを画面幅600px以上の時、2カラムで表示
の3点は実現できているのですが、
・main-wrapをmax-width:1000pxで表示
が実現できません。
画面幅1000px以上になるようにしても、main-wrapの幅が
600pxほどにしかならず、いろいろと数値を変えたりはしてみたのですが、
行き詰っております。
勉強中のため、いろいろとコードに不備があるかとは思いますが、
ご教授いただけると幸いです。
よろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/09/03 08:51