Is possible set position of absolute element with count height of element above? The goal is get elements with class "pgafu-post-categories"
to one line above H2, when is different length.
pgafu-post-categories {
position: absolute;
top: -82px;
width: fit-content;
white-space: nowrap;
padding: 4px 16px;
font-size: 14px;
}
<div class="row">
<div class="column">
<div class="image-wrapper"></div>
<h2>Small title</h2>
<div class="pgafu-post-categories">category</div>
</div>
<div class="column">
<div class="image-wrapper"></div>
<h2>Long two <br> lines title</h2>
<div class="pgafu-post-categories">category</div>
</div>
<div>
Most simple would be move <div class="pgafu-post-categories">
above <h2>
in HTML, but it is not possible edit HTML code. Is there a way to do this with css?
Edit: Maybe there is possible also use jquery/javascript to count height of h2 element and then set position to absolute element?
2
Answers
Use flexbox:
You can use
display: flex;
and the propertyorder: 1;
on the children. If you want it to only apply to a specific column you can use the classcolumn--move-category
on the column in my example. Hope this helps.