私は、次のコードを持っている:私はそれは黄色のボックスと青のボックスの両方に重なるように約30ピクセルを上に移動する赤いボックスが欲しい内箱を上に移動して外箱をCSSで固定する方法は?
<html>
<head>
<style>
#yellow {height:100px; background:yellow;}
#blue {background:blue;}
#red {background:red; width: 400px; height: 100px; margin:0px auto;}
</style>
</head>
<body>
<div id="yellow"></div>
<div id="blue">
<div id="red">Lots of content goes in here that will expand the outer blue box as well</div>
</div>
</body>
</html>
を。私が#red {margin:-30px auto 0px auto;}
をしようとすると、青色のボックスが赤いボックスで30ピクセル上に移動しました。
どのように私は、赤いボックスを上に移動し、黄色と青の両方に重なりますか?
#blueの下にスペースを入れたくない場合は、margin-bottom:-30pxを#redに追加します。 –