综合编程

Positioned 3 different divs

微信扫一扫,分享到朋友圈

Positioned 3 different divs
0

I have 3 different divs in html file.

div {
  width: 200px;
  height: 200px;
  position: absolute;
}

.second {
  background: red;
  left: 200px;
  top: 200px;
}

.third {
  background: green;
  top: 400px;
  left: 400px;
}

.first {
  background: yellow;
}
<div class="first"></div>
<div class="second"></div>
<div class="third"></div>

I want to move one div.Anyone I want.But when I move any divs this must effect others.Example:When I added margin to .second div this divs change position in page flow.I want this effects to .first and .third div.How can I do it?

Expected output:

The purpose of CSS position:absolute is to remove the element from the document flow so that changing the margins or size won’t effect other elements around it.

If you want your <div> s to be affected by margins of other divs, instead of using position:absolute try using float:left (or flexbox for a more powerful solution).

阅读原文...

Hello, buddy!

竞争才刚刚开始:农村宽带缩影

上一篇

投资界24h|牛仔裤品牌李维斯要重新IPO;头腾大战升级,字节跳动否认“多闪”从未出现在应用宝

下一篇

您也可能喜欢

评论已经被关闭。

插入图片
Positioned 3 different divs

长按储存图像,分享给朋友