Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] CSS Question

Started by NickHighIQ Mar 12, 2008 at 12:29 AM 3 replies 1k views
Original Post
NickHighIQ
NickHighIQ
Is there any way to create custom pseudo-classes? Or is there a better way of doing what I want to do? I'm a total newbie to CSS. I am creating custom controls, and these custom controls have custom width and style properties. Basically, I want a 'button' class from which 'stylishButton' inherits. I then want to be able to slap a pseudo-class (that's what I think I want to do) on it to say whether it is 'large', 'medium' or 'small'. These custom width and style properties are just enums which I want to set the meaningful values of in the CSS file. Are custom pseudo-classes what I actually want to do, or something else? [Edited by - NickHighIQ on March 12, 2008 5:00:06 AM]
Nick Wilson - Junior C# Developer | See my crappy site
Kylotan
Kylotan
No, you just want extra classes. Put the common stuff in 'stylishButton', put the size stuff in 3 other classes, and give the object both classes in your HTML.

Or, just have 3 classes, and specify the non-size styles together in one block, and the sizes individually.

Pseudo-classes are for different contextual states of a single class, rather than a way to distinguish between similar things that you think should be one class but could just as easily be several.
NickHighIQ
NickHighIQ
So I separate them into classes like:

button
stylishButton
small
medium
large

Then in html:

class="stylishButton,small"

Is that right?
Nick Wilson - Junior C# Developer | See my crappy site
Wan
Wan
Quote:
Original post by NickHighIQ
Is that right?

Replace the comma with a space: class="stylishButton small"
Kylotan
Kylotan
You also don't need the 'button' class at all, just the 1 class for the shared stuff and 3 for the separate stuff.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.