相对于另一个DIV的位置DIV?

编程入门 行业动态 更新时间:2024-10-28 12:28:40
本文介绍了相对于另一个DIV的位置DIV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以相对于另一个DIV定位DIV?我想这可以通过首先将它放在参考DIV,然后使用 position:relative 。但是,我不知道如何做,而不影响参考DIV的内容。如何正确地完成此操作?

请参阅: jsfiddle/CDmGQ

谢谢! =)

解决方案

将父DIV的位置 c $ c> relative (指定偏移量,即 left , top 没有必要),然后将 position:absolute 应用到您想要的偏移量的子DIV。 这很简单,应该做的很好。 p>

Is it possible to position a DIV relative to another DIV? I imagine this can be done by first placing it inside of the reference DIV, and then using position: relative. However, I can't figure out how to do this without affecting the contents of the reference DIV. How can I do this properly?

See: jsfiddle/CDmGQ

Thanks! =)

解决方案

First set position of the parent DIV to relative (specifying the offset, i.e. left, top etc. is not necessary) and then apply position: absolute to the child DIV with the offset you want. It's simple and should do the trick well.

更多推荐

相对于另一个DIV的位置DIV?

本文发布于:2023-10-08 09:53:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472279.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:相对于   位置   DIV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!