My attempt to align an element using a certain method has hit a snag when trying to retrieve the current height of the element using CSS.
Below is the code that works, albeit with some extra parts:
section{
margin-top:calc(50vh);
margin-bottom:calc(50vh);
}
<section style="background:red;">q<br><br>q</section>
The following code represents what I am aiming for, but unfortunately it's not functioning as intended:
section{
margin-top:calc(50vh - attr(clientHeight));
margin-bottom:calc(50vh - attr(clientHeight));
}
<section style="background:red;">q<br><br>q</section>
I'm seeking guidance on how to obtain the height of an element, with the focus being solely on this aspect rather than vertical alignment of elements. Additionally, I prefer a solution that relies solely on CSS.