将子div放在父div之上

编程入门 行业动态 更新时间:2024-10-28 12:17:39
本文介绍了将子div放在父div之上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 <div id="1"> <div id="2"> </div> </div>

我无法将div2放在div1之上(不是在z-索引中,而是在垂直维度中)。 负面位置:顶部不工作,看起来像父母的顶部边界div是儿童的限制。

I cant position div2 above div1 (not in the z-index but in vertical dimension). Negative position: top not working, seems like top border of parent div is limit for childrens.

|-------| | div2 | ------| | | |_______| | | | div1 | |__________|

推荐答案

以数字开头的类名无效,尽管它可能适用于某些浏览器。使用 div1 或 div2 并且这应该起作用。查看此答案

Class names starting with digits are not valid, although it may work in some browsers. Use div1 or div2 and that should work. Take a look at this answer for a good explanation of valid CSS class names.

评论后更新:

好的好吧,没有看到有问题的代码,很难看到问题出在哪里。但是使用这个CSS你可以重现你的图:

Ok, well, without seeing the offending code, it's hard to see where the problem is. But using this css you can reproduce your diagram:

#div2 { position:relative; top:-30px; left:100px; }

因为我认为你已经知道了......但也许你忘记了位置:相对于?无论如何,请参阅小提琴。

As I think you already know.. but maybe you forgot the position:relative? Anyway, see it working in this fiddle.

更多推荐

将子div放在父div之上

本文发布于:2023-10-08 04:39:46,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:放在   div

发布评论

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

>www.elefans.com

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