Are there any fixes to fix this?
With pure CSS, NOT . Who says this is the Mozilla overlords, in their documentation :
In contrast, an element that is positioned is taken out of the flow and thus takes up no space when placing other elements. The absolutely positioned element is positioned relative to nearest positioned ancestor. If an anchor position does not exist, the initial container is used.
In a free translation of the part that interests us: an element that is positioned absolutely is taken out of the flow and does not takes up space when other elements are placed .
This means that, for all intents and purposes, an absolutely positioned element does not exist for your parent in terms of height or width definition of the latter, so its dimensions will not change the dimensions of other elements above it. overflow: auto
and things like that will not work.
With JS? SIM .
As you well asked, this is a fix , since you are trying to reach a goal with things that have not been done for it.
I did a fiddle to demonstrate the "technique". The idea is basically to add the size of the items within the% co_of% parent, and assign the result as the height of this div
.
var blocks = $('.block').length;
var altura = $('.block').height();
altura *= blocks;
$('.mockup').css('height', altura);
In my fiddle, the items are called div
, to make things easier. If you add or remove block
s from html, be sure to increase or decrease the variable .block
in $total
accordingly, so compiled SCSS
does not cause problems. Again, this is a hack . You will have to adjust things to your code. If you're working with css
, for example, you'll have to take into account the size of the edges in the calculation of heights.