I want a margin-left of a div, .div1 equal to a padding-left of another div, .div2, I know you could just set the value of a variable and use it for corresponding attributes of both divs, but I need it to be dynamic.
<code>.div1{
margin-left:1.8%;
}
:root{
--gappercent:/*.div1's margin-left value*/;
}
.div2{
padding-left: var(--gappercent) /* OR .div1's margin-left value*/;
}
</code>
<code>.div1{
margin-left:1.8%;
}
:root{
--gappercent:/*.div1's margin-left value*/;
}
.div2{
padding-left: var(--gappercent) /* OR .div1's margin-left value*/;
}
</code>
.div1{
margin-left:1.8%;
}
:root{
--gappercent:/*.div1's margin-left value*/;
}
.div2{
padding-left: var(--gappercent) /* OR .div1's margin-left value*/;
}
I’d like variable (–gappercent) to get assigned with the value of div1’s left margin
New contributor
Udiolvosuzuatsun is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.