ホームページ >ウェブフロントエンド >htmlチュートリアル >位置の混乱、解決に役立ちます_html/css_WEB-ITnose
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> *{ margin:0; padding:0; } .parent{ background: red; position: absolute; left:60px; width: 300px; height: 300px; } .childRight{ background: blue; width: 240px; position: relative; right:60px; } .child-Right{ background: yellow; width: 240px; position: relative; right:-60px; } .childLeft{ background: blue; width: 240px; position: relative; left:60px; } .child-Left{ background: yellow; width: 240px; position: relative; left:-60px; } </style></head><body> <div class="parent">parent <div class="childRight">childRight</div> <div class="child-Right">child-Right</div> <div class-"childLeft">childLeft</div> <div class="child-Left">child-Left</div> </div> <div style="width:300px;height:300px;border:1px solid #000">hello</div></body></html>
はい、
相対配置の場合、要素は元の位置に基づいてオフセットされ、プラス 60 ピクセルの右オフセットはマイナス 60 ピクセルの左オフセットと等しくなります。
色を表示しないのはなぜですか
8e655fb6b9996c9afc3890cd297bf776childLeft16b28748ea4df4d9c2150843fecfba68