How We Could Write Better CSS
21–30 of 55 posts
Re: How We Could Write Better CSS
#22The author's wish is coming true. CSS techniques are already becoming unified through frameworks like Bootstrap and Foundation.
Re: How We Could Write Better CSS
#23I find that following a prefix method works quite well for organizing a lot CSS. For example (using sass): .home-header-h1{ font-size: 20pt; padding: 0px; margin: 0px; line-height: 1.3; } .home-header-h1-blue{ @extend .home-header-h1; color: blue; } .home-header-h1-green{ @extend .home-header-h1; color: green; } This helps keep classes out of your HTML and avoids large amounts of nested CSS. Here's the compiled sourc…
Re: How We Could Write Better CSS
#24Re: How We Could Write Better CSS
#25Deeply nested CSS selectors in the source (like the ones in your MixPanel examples) are often a sign of CSS preprocessors in use. Using a tool like LESS or Stylus, MixPanel is probably including mixins in their styles that allow them the same modular flexibility you describe without cluttering the HTML with confusing, non-semantic classes like "mrm". Edit: your site's visual design is awesome, btw
This * 1000. Just because the output isn't 100% optimal doesn't mean the input isn't sane, maintainable, or clean.
Re: How We Could Write Better CSS
#26Re: How We Could Write Better CSS
#27I think the Facebook Way (tm) has its pros, but using page-level specificity is a great way to avoid specificity hell.
To be more specific, for a site with vastly different pages, it's best to have page or section level class that limits the scope of each css definition, so the person making change to one section of the site will not accidentally break other pages. Also, with little base style, there is less need to override styles with more specificity.
For such a site, CSS like this tend to be easier to maintain:
#home-page h2 { /* home page title styles / }
.news-item h3 { / news item title / }
#widget-page h2 { / widget page title / }
.widget-item h3 { / individual widget title */ }
Re: How We Could Write Better CSS
#28OP here. Thanks for the feedback. A lot of people seem to be getting hung up on the sass thing. I'm all for sass, I don't think using 15 CSS classes for margins is the best way to handle this. I just wanted to use a watered down illustration for those who don't yet understand sass. Ideally, this should al be abstracted into variables/mixins/extends. My main point though, is that I'd like to see us working together to…
Re: How We Could Write Better CSS
#29Re: How We Could Write Better CSS
#30OP here. Thanks for the feedback. A lot of people seem to be getting hung up on the sass thing. I'm all for sass, I don't think using 15 CSS classes for margins is the best way to handle this. I just wanted to use a watered down illustration for those who don't yet understand sass. Ideally, this should al be abstracted into variables/mixins/extends. My main point though, is that I'd like to see us working together to…
Extremely confused by the fact that there's no article navigation on your site. I just wanted to read more...
I've two other articles: http://www.colmtuite.com/three-reasons-why-wireframing-tools... http://www.colmtuite.com/a-more-flexible-development-framewo...