I'am not profficient in html and css, so i dont even know how to search for a post here in StackOverflow I excuse my selfe beforehand if this is an duplicate.
i want to do something like this:
margin-horizontal
{
margin-left: var;
margin-right: var;
}
<div style="margin-horizontal: 50px">
Is there a way to accomplish this behavior?
CodePudding user response:
CSS variables are possibly what you are looking for. Your example would look as follows.
CSS:
:root {
--space: 50px;
}
.margin-horizontal
{
margin-left: var(--space);
margin-right: var(--space);
}
HTML:
<div class="margin-horizontal">...</div>
CodePudding user response:
What exactly are you hoping to get?
If you want to use your css class in your html you want to give the div a class with the name 'margin-horizontal'. like this: div