2
Note:
Can someone with 300 reputation please add the tag, "scss" to this question? I'd be very appreciative.
My code (scss):
.cinderblock {
@include minwidth();
background-image:url("images/cinderblock.jpg");
background-position:top center;
background-color:#b79966;
height:528px;
.wrapper {
background-image:url("images/home-decorito.jpg");
height:488px;
}
.big-yellow-button {
width: auto;
position:absolute;
bottom:84px;
}
}
What I need it to look like:
.cinderblock {
@include minwidth();
background-color:#b79966;
background-image:url("images/cinderblock.jpg");
background-position:top center;
height:528px;
.big-yellow-button {
bottom:84px;
position:absolute;
width: auto;
}
.wrapper {
background-image:url("images/home-decorito.jpg");
height:488px;
}
}
The solution must:
- Alphabetically sort the
- properties of the parent block
- properties of the child blocks
- child blocks
- Preserve indentation
- Bonus: Correct inconsistency in whitespace (e.g. spaces between property names and values)
If we leave the technical aspect of your question aside, this is not a very good idea. Selectors should be grouped by position on the page/in the site, cascading order, semantics… alphabetical sorting is probably worse than no order at all. – romainl – 2013-04-11T06:41:13.043
Actually, the best way to architect css is by specificity, especially when you're working on large sites like I do. Check it out: http://www.youtube.com/watch?v=R-BX4N8egEc
– gmeben – 2013-04-11T12:05:32.120Hmm, that's what I meant with "cascading oder". Alphabetical order sucks, anyway. – romainl – 2013-04-11T12:08:06.760
Sorting properties and child selectors alphabetically is not a bad idea at all, as it cascades just fine and doesn't affect specificity. Please stay on topic. – gmeben – 2013-04-11T12:12:16.450
It affects readability and comprehension which should be the primary concern when talking about sorting text/code.
width: 23px;
andheight: 46px;
are conceptually related and thus should stay together, same thing formargin
andpadding
orposition
,top
,bottom
,left
andright
. – romainl – 2013-04-11T13:02:55.393If that's your cup of tea, then cool. Personally, I prefer alphabetical because if I'm looking for a specific property amongst a long list of declarations, I know where to look that much more quickly. When you work with large amounts of CSS/SCSS, it becomes a waste of time to manually organize properties (hence, my wish to automate) as they do not affect specificity. I'd much rather be using that time to manually organize selector order. – gmeben – 2013-04-11T13:28:47.470
OK, to each his/her own. I really heavily on search for that. – romainl – 2013-04-11T15:09:54.690