<section class="cook">と <section class="source_water">のそれぞれを親要素として、position relativeとして、それぞれの子要素にposition absoluteで位置を指定して文章と画像を挿入していますが、<section class="source_water">の子要素が <section class="cook">の要素の上に張り付いてきます。
親要素の指定の仕方が間違っているのでしょうか?
HTML
1 <!-- 温海料理 --> 2 3 <section class="cook"> 4 <img class="cook_img" src="img/menu-top.jpg" alt="" width="1050" height="545"> 5 6 <figure class="cook_paragraph"> 7 8 <h2>出迎え得るのは</h2> 9 <h2>至極の温泉料理</h2> 10 <p>最も旬の食材を愉しむ、最高の贅沢を</p> 11 <p>最高級A5ランクの米沢牛と共に頂く。</p> 12 <p>あなたの人生史に残る「極上の感動」を</p> 13 <p>お約束します。</p> 14 <span>料理について</span> 15 16 </figure> 17 18 </section> 19 20 <!-- 温泉について --> 21 22 <section class="source_water"> 23 <img class="source_water_img" src="img/onsen-top.jpg" alt="" width="1050" height="545"> 24 25 <figure class="source_water_paragraph"> 26 27 <h1>疲れ切った身体にやすらぎを</h1> 28 <h1>温海の源泉に癒やされて</h1> 29 <p></p> 30 <p>古くは弘法大師の病をも治療したと言われる熱海の泉質。</p> 31 <p>現代人の疲弊しきった身体を修復する最高級の湯治場として<p> 32 <p></p> 33 <p>ご活用ください。<p> 34 <span>温泉について</span> 35 36 </figure> 37 38 </section> 39
CSS
1 2/* cook */ 3 4 5.cook { 6 position: relative; 7 margin-top: 106px; 8 background-color: violet; 9 10} 11 12 13.cook_img { 14 position: absolute; 15 left:1187px; 16} 17 18.cook_paragraph { 19 20 position: absolute; 21 /* display: inline-block; */ 22 top:138px; 23 left:408px; 24 background-color: red; 25 26} 27 28 29/* source_water */ 30 31 32.source_water { 33 position: relative; 34 margin-top: 106px; 35 background-color: blue; 36} 37 38.source_water_img { 39 position: absolute; 40 left:50px; 41} 42 43 44.source_water_paragraph { 45 position: absolute; 46 display: inline-block; 47 top:138px; 48 left:408px; 49 background-color: red; 50 51} 52 53
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/05/15 02:58