+ 3

Deleting preserved space of (Position: relative) elements

I would like to know if there is any way to delete or hide the preserved space for relatively positionated elements without hiding the element itself?

15th Jul 2017, 9:41 AM
Ledio Deda
Ledio Deda - avatar
4 odpowiedzi
+ 4
With 'absolute' position, the left/right/top/bottom properties values are used relatively to the first positioned parent element, rather than the initial position of the element with 'relative'... Anyway, knowing that, you can workaround to obtain similar behaviour as 'relative' to an 'absolute' element by defining a container to your 'absolute-fake-relative' element and giving it a 'relative' position: as the only content is 'absolute' it will not reserve space inside the container, which as positionned element takes the minimal space required for none content (width:0, height:0), so the coordinate origine referent for your 'fake-relative' element is now the position of the container, right now the initial position of your 'fake', so you get what you expect: a 'relative' position without reserving space ;)
15th Jul 2017, 10:07 AM
visph
visph - avatar
+ 4
The only way to not reserve space for element is to position it as 'absolute' (or 'fixed', which is an 'absolute' special case)...
15th Jul 2017, 9:43 AM
visph
visph - avatar
0
Am i wrong or if you use absolute, you cant use left right...., i mean the element is not positionated where you want, but is set at the nearest parent element or something???
15th Jul 2017, 9:50 AM
Ledio Deda
Ledio Deda - avatar
0
I think i got it... Hope it works and thanks👍
15th Jul 2017, 10:14 AM
Ledio Deda
Ledio Deda - avatar