Re: Add margin-x and margin-y properties (same for padding and border-*)

Matthew, please read my proposal more carefully. It contains answer to your question (see text beginning from "One could argue").


16.01.2012, 14:44, "Matthew Wilcox" <mail@matthewwilcox.com>:
> Sorry, I'm not sure I understand the rationale behind this? Doesn't the shorthand property already get rid of the repetition?.example { margin: 1em 0; }
> does exactly what your first example does.
>
> 2012/1/16 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/

Received on Monday, 16 January 2012 13:11:16 UTC