- From: Marat Tanalin | tanalin.com <mtanalin@yandex.ru>
- Date: Mon, 16 Jan 2012 17:12:17 +0400
- To: Alan Gresley <alan@css-class.com>
- Cc: www-style@w3.org
16.01.2012, 06:17, "Alan Gresley" <alan@css-class.com>: > On 16/01/2012 9:20 AM, Marat Tanalin | tanalin.com wrote: > >> Hello. It would be nice to have ability to specify vertical and horizontal margins, paddings, and border-* subproperties once, without need for duplicating same value in separate subproperties like margin-top/margin-bottom. >> >> Vertical margins are margin-top and margin-bottom. Horizontal margins are margin-left and margin-right. >> >> For example, vertical margins (paddings, border-width, border-style) are _very often_ specified equal. Currently we are forced to inevitably specify same value twice: >> >> .example { >> margin-top: 1em; >> margin-bottom: 1em; >> } >> >> It makes sense to introduce more elegant syntax: >> >> .example {margin-y: 1em; } >> >> One could argue why not just specify it as {margin: 1em 0}? Answer is that it's inappropriate if we need to _override_ vertical (or horizontal) margins _already specified_ as 'margin' property for more general class. For example: >> >> .general {margin: 1em 20px; } >> .general.lorem {margin-y: 2em; } >> .general.ipsum {margin-y: 3em; } >> >> Currently we are forced to duplicate either vertical margin (value for more specific class): >> >> .general.lorem {margin-top: 2em; margin-bottom: 2em; } >> .general.ipsum {margin-top: 3em; margin-bottom: 3em; } >> >> or horizontal one (repeating value already specified for more general class): >> >> .general.lorem {margin: 2em 20px; } >> .general.ipsum {margin: 3em 20px; } >> >> This is non-DRY and makes CSS-code littered / less readable and eventually making maintenance harder. >> >> Introducing margin-y and margin-x properties would make things simpler and smarter. >> >> (Same applies to at least padding and border-* properties like border-width as well as any other properties where vertical/horizontal values make sense.) >> >> Thanks. > > So how does this overrule default margins [1] on block level elements or > overrule the property 'margin'? > > May I suggest this. > > .example { margin: y(1em); } > > .general { margin: 1em 20px; } > .general.lorem { margin: y(2em); } > .general.ipsum { margin: y(3em); } > > 1. http://css-class.com/test/css/defaults/default-margins.htm > > -- > Alan Gresley > http://css-3d.org/ > http://css-class.com/ I'm not sure what does "overrule" mean here. Just in case: {margin-y: 1em} should be 100% equivalent to {margin-top: 1em; margin-bottom: 1em; }.
Received on Monday, 16 January 2012 13:13:12 UTC