Here's an option using CSS tags .
The idea here starts from a base value set in the variable --altura
, then we will make the overhide (overwrite) the value of that variable where we want. Note that you only need to change the value of the variable and will replace both height
and line-height
of the element. In short you only declare 1 variable value that replaces the value of the 2 attributes that you want to change I left commented in the code to facilitate
:root {
--altura: 100px; /* valor "base" */
}
.altura, .altura2, .altura3 {
height: var(--altura); /* valor "da variável" */
line-height: var(--altura); /* valor "da variável" */
}
.altura2 {
--altura: 200px; /* overhide do valor da variável */
}
.altura3 {
--altura: 300px; /* overhide do valor da variável */
}
<div class="altura" id="1" style="background-color: red;">1</div>
<div class="altura2" id="1" style="background-color: blue;">2</div>
<div class="altura3" id="3" style="background-color: green;">3</div>
See the browser support, please note that it just does not work in IE link