I try to use CSS variables for width, heights and margin of a ::before
element. It works all right for width and margin, but heights is 0.
Is there a way to resolve that? What is wrong?
html {
--red_W: 80%;
--red_H: calc(var(--red_W) / 4);
--red_H_neg: calc(var(--red_H) * -1);
}
.bottomline {
margin-top: var(--red_H);
text-align: center;
border-top: 10px solid green;
}
.inside::before{
content: '';
background-color: red;
width: var(--red_W);
height: var(--red_H); /*this does not seem to work*/
margin: var(--red_H_neg) auto 0;
display: block;
position: relative;
}
<div class="bottomline">
<div class="inside">
</div>
</div>