Somewhere along the line I decided that having classes for position would be a good thing. So I created the following:
.prel {position: relative}
.pfix {position: fixed}
.pabs {position: absolute}
These classes are apply to thousands of little elements floating around, but they’re beginning to bug me.
The elements to which my relative position class applies, for example, all belong to about seven other classes. So I could just do this (where class1-class7 are all existing classes used for other purposes):
.class1,.class2...class7 {position: relative}
The reason for the question is this: I have this sneaking feeling that this is going to be one of those changes I make that I need to reverse out later. So I’m looking for advice as to which is the best way forward. Does it make a difference at all? Why do big sites seem to use these position classes?
I do lot of jQuery class-based searches if that is significant.
In principle, it’s a bad idea. It’s not really any different from applying inline styles to all your elements. Best practice is good separation of style and content.
As you’ve already mentioned, you will most likely need to change out loads of these classes later. It’s going to be a nightmare to maintain.