z-indexを例えば10に指定すると、その要素はfloatと同じく浮いていることになるのでしょうか。
浮いているとしたら、floatと同じようにclearプロパティやclearfixの技法で直すことはできるのでしょうか。
ある要素にposition:fixedとz-index:10を指定すると、その下の要素が上の要素に潜り込み重なってしまいます。下の要素のmargin-topを75pxに指定してレイアウトを整える以外に解決法はあるのでしょうか。
HTML
1<html lang="ja"> 2<head> 3 <meta charset="UTF-8"> 4 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 5 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 6 <title>Document</title> 7 <link rel="stylesheet" href="stylesheet.css"> 8</head> 9<body> 10 <header> 11 <div class="container"> 12 <div class="header-left"> 13 <img src="images/isaralogo.png" alt="isara" class="header-logo"> 14 <p class="h1">バンコクのノマドエンジニア育成講座</p> 15 </div> 16 <div class="header-right"> 17 <a href="#">お問い合わせ / 資料請求はこちら</a> 18 </div> 19 </div> 20 </header> 21 <div id="wrap"> 22 <section class="top"> 23 <p class="text1">プログラミングで</p> 24 <p class="text1">人生の安定を手にいれよう</p> 25 <img src="images/isaralogolarge.png" alt="isara"> 26 <p class="text2">バンコクのノマドエンジニア育成講座</p> 27 <p class="text2">iSara[イサラ]</p> 28 </section> 29 30 </div> 31</body> 32</html>
CSS
1@charset "utf-8"; 2 3* { 4 box-sizing: border-box; 5 text-decoration: none; 6} 7body { 8 margin:0; 9} 10header { 11 height:75px; 12 width:100%; 13 background-color:white; 14 position:fixed; 15 top:0px; 16} 17header:after { 18 content:""; 19 display:block; 20 clear:both; 21} 22.container { 23 width:1170px; 24 height:75px; 25 margin:0 auto; 26} 27.header-left { 28 float:left; 29 width:400px; 30 height:75px; 31} 32.header-logo { 33 margin-top:17px; 34 width:120px; 35 float:left; 36} 37.header-left .h1 { 38 margin: 37px 0 0 0; 39 font-size: 14px; 40 color: #333333; 41 font-weight:600; 42 letter-spacing: 2px; 43} 44.header-right { 45 float:right; 46 width:320px; 47 height:45px; 48 margin-top:15px; 49 background-color: #da6b64; 50 border-radius:25px; 51} 52.header-right a { 53 line-height: 45px; 54 font-weight:300; 55 font-size: 14px; 56 text-align:center; 57 color:white; 58 letter-spacing: 2px; 59 display:block; 60} 61.header-right:hover { 62 background-color:#dc143c; 63} 64#wrap { 65 margin-top:75px; 66} 67.top { 68 width:1170px; 69 margin:0 auto; 70} 71
回答4件
あなたの回答
tips
プレビュー