以下のようなケース(全体のbackgroundをgreenにしたい)なのですが、cssでpositionを設定しつつ、z-indexを設定しても.wrapperのグリーンが前に出てくれません。できればheaderはabsoluteのままが良いのですが、これが効かない理由と解決方法について、アドバイスを頂きたく投稿させていただきました。
よろしくお願い申し上げます。
html
1<body> 2 <div class="wrapper"> 3 <div class="header"></div> 4 </div> 5</body>
css
1.wrapper{ 2 width:500px; 3 height:500px; 4 background:green; 5 position:relative; 6 z-index:2; 7} 8 9.header{ 10 width:100%; 11 height:100px; 12 background:red; 13 position:absolute; 14 z-index:1; 15}
この先どうしたいのか追記願います。(.headerの内容が何もないですし)
これだけでは意図は伝わりづらいと思います。
回答3件
あなたの回答
tips
プレビュー