Skip properties in CSS shorthand for padding, margins, etc.
Is there a way to specify a CSS property, omitted in shorthand with padding, border, border, etc.
Like padding: <skipped> 1em 2em
instead of:
padding-right: 1em
padding-bottom: 2em
+3
mahemoff
source
to share
2 answers
I think it is best to assign a value auto
, although this will only set it to whatever [browser] default it may have, I assume it will reset to 0 for padding [depending on on the element].
Other than that, no.
+1
sg3s
source
to share
The correct way to skip properties is not to use the shorthand version:
padding-bottom: 2em;
padding-right: 1em;
It's not as elegant as:
padding: same 1em 2em same;
but it just doesn't exist in pure CSS. If you are using server side extensions like LESS or SASS there might be a syntax for that; if not, it could be added with relative ease.
+5
zzzzBov
source
to share