SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru pinch's Avatar
    Join Date
    Mar 2005
    Posts
    688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Off the deep end with classes?

    I'm working on a web project that is extremely large and over the course of the project I've created quite a few classes that I re-use. Many times I need to nudge an element a few pixels here or there, and as a result I started created classes such as:

    Code:
    .marginRight1 {margin-right:1px;}
    .marginRight2 {margin-right:2px;}
    .marginRight3 {margin-right:3px;}
    .paddingLeft1 {padding-left:1px;}
    .paddingLeft2 {padding-left:2px;}
    .paddingLeft3 {padding-left:3px;}
    I use the classes when all I need is a 'nudge' and no other real stylings. But, now that the project has got quite large, it seems I have close to 60 classes for these pixel nudges.

    One side says I've gone overboard, the other says doing this is much better than creating more classes that essentially do the same thing. Is this a bad idea?

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,122
    Mentioned
    29 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by pinch View Post
    One side says I've gone overboard, the other says doing this is much better than creating more classes that essentially do the same thing. Is this a bad idea?
    yep. It doesn't look good.
    If you're adding these classes a lot of times - then you really should adding padding to the parent so you don't have to nudge all the children.

  3. #3
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use shorter classnames to reduce size of css file and size of your HTML file!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •