相对定位元素而不占用文档流中的空间

编程入门 行业动态 更新时间:2024-10-25 10:22:19
本文介绍了相对定位元素而不占用文档流中的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

解决方案

如何相对定位一个元素,并且不占用文档流中的空间? 试图做绝对定位的声音。另一方面,您可以通过创建零宽度,零高度,相对定位的元素,基本上仅为了创建位置的参考点的目的而创建伪相对元素,并且绝对定位元素

< div style =position:relative; width:0; height:0> < div style =position:absolute; left:100px; top:100px> 我100px偏移从我应该是,从顶部和左边。 < / div> < / div>

How can I relatively position an element, and have it not take up space in the document flow?

解决方案

What you're trying to do sounds like absolute positioning. On the other hand, you can, however, make a pseudo-relative element, by creating a zero-width, zero-height, relatively positioned element, essentially solely for the purpose of creating a reference point for position, and an absolutely positioned element within that:

<div style="position: relative; width: 0; height: 0"> <div style="position: absolute; left: 100px; top: 100px"> Hi there, I'm 100px offset from where I ought to be, from the top and left. </div> </div>

更多推荐

相对定位元素而不占用文档流中的空间

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

发布评论

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

>www.elefans.com

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