CSS位置:绝对+动态高度 [英] CSS position:absolute + dynamic height

查看:183
本文介绍了CSS位置:绝对+动态高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4 < div> 个标签,所有在 position:absolute 他们使用顶部

I have 4 <div> tags one after the other, all in position:absolute and I align them using top and left.

标签包含动态内容,div的高度根据其中的文本量而更改。然而,当我设置所有div的 top left 时,第4个div受第3个动态div。

The 3rd div tag contains dynamic content and the height of the div changes according to the amount of text in it. However, as I set the top and left of all divs, the 4th div is affected by the height of the 3rd dynamic div.

如何解决这个问题?

http://jsfiddle.net/25Xrh/

推荐答案

您可以尝试在父div中包装4个div并绝对定位。然后,您可以允许其中一个子div的位置影响另一个。

You may want to try wrapping the 4 divs in a parent div and absolutely positioning that. Then you can allow the position of one of the children divs to affect another.

http://jsfiddle.net/25Xrh/5/

您的解决方案意味着无论您尝试影响 top:60px left:180px 阻止其移动到此处以外的位置,因此动态内容div无法重新定位。

The solution you had meant that no matter what you tried to affect the top:60px and left:180px stopped it from moving anywhere other than this, so the dynamic content div wasn't able to reposition it.

这篇关于CSS位置:绝对+动态高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆