Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip properties in CSS shorthand for padding, margin, etc

Tags:

css

shorthand

Is there a way to specify a CSS property is skipped in the shorthand, with padding, border, margin, etc.

Like padding: <skipped> 1em 2em instead of:

padding-right: 1em
padding-bottom: 2em
like image 677
mahemoff Avatar asked Mar 25 '12 23:03

mahemoff


2 Answers

The correct way to skip properties is to not use shorthand:

padding-bottom: 2em;
padding-right: 1em;

It's not as elegant as:

padding: same 1em 2em same;

but it simply doesn't exist in pure CSS. If you use server-side CSS extensions such as LESS or SASS, there may be syntax to do that; if there isn't, it could be added with relative ease.

like image 145
zzzzBov Avatar answered Sep 20 '22 23:09

zzzzBov


I think your best bet is to assign the value auto though that will only set it to any default [browser] value it may have, I'm guessing that for padding it will reset it to 0 [depending on the element].

Other than that, no.

like image 39
sg3s Avatar answered Sep 19 '22 23:09

sg3s