开发者

div on another div by css

开发者 https://www.devze.com 2023-04-04 08:17 出处:网络
I wanna set one div to be shown on another one. I can do it by enter it in end开发者_如何学Go of html code after other one,but I wanna do it by css.

I wanna set one div to be shown on another one.

I can do it by enter it in end开发者_如何学Go of html code after other one,but I wanna do it by css.

how can I do it?


I'm guessing this is what you mean: having the divs overlap when placed one after the other in the markup? You can achieve this by making them position: absolute.

<div id="div1">
</div>
<div id="div2">
</div>

#div1, #div2 {
    position: absolute;
}
#div1 {
    background-color: red;
    width: 100px;
    height: 100px;
}
#div2 {
    background-color: blue;
    width: 100px;
    height: 100px;
    top: 5px;
    left: 5px;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消