Hacker News new | ask | show | jobs
by uptown 4775 days ago
Speaking of class-naming, has anybody come up with a good naming-scheme for classes used to add padding (or margins) to elements?

Sometimes I've create things like this: .pad_10_5_20_10 to avoid having to declare each one separately, but I'm sure there's a more-elegant way to do it. Of course, I can always define that padding directly in a more-generic class-name like .sidebar .... but there are cases where a pad class is more-desirable.

2 comments

I've adopted the 'BEM' way of naming my css classes and so on. It's pretty convenient, and it grows on you pretty quickly. I hope this helps - http://csswizardry.com/2013/01/mindbemding-getting-your-head...
Try the OOCSS classes:

/spacing.css/ /* spacing helpers p,m = padding,margin a,t,r,b,l,h,v = all,top,right,bottom,left,horizontal,vertical s,m,l,n = small(5px),medium(10px),large(20px),none(0px) */

https://gist.github.com/cloudchen/5626174

Pretty good approach. Thanks for the link.