4

I'm using a style sheet .t-button for buttons defined as..

.t-button
{
    border-color: #a7bac5;
    color: #333;
}

the definition of this style is generated at runtime in an .axd file

Is there a way to apply this specific style sheet to all normal buttons in my application? something like...

button, input[type="button"], input[type="submit"]  
{
  /*apply "t.button" */  
}
1
  • 1
    I have often hoped this was the case (being able to apply one elements style to another with a call to the other), but alas, I have never figured out how to do this. I hope I am wrong, but I wonder if it is really possible... Commented Jun 26, 2011 at 22:59

3 Answers 3

5

CSS can't do this, but precompiled CSS extensions like LESS and SASS can.

Example stolen from LESS's front page:

.rounded-corners (@radius: 5px) {
  border-radius: @radius;
  -webkit-border-radius: @radius;
  -moz-border-radius: @radius;
}

#header {
  .rounded-corners;
}
#footer {
  .rounded-corners(10px);
}

and from SASS:

.error {
  border: 1px #f00;
  background: #fdd;
}

.badError {
  @extend .error;
  border-width: 3px;
}
Sign up to request clarification or add additional context in comments.

Comments

1

Not something you can do at the moment with pure CSS, afaik.

You can use "extensions" in Js or your favourite servers-sided technology that "compiles" CSS, however. ( http://sass-lang.com/ )

Comments

1

Basically no, you'll either have to modify the code creating the axd file to add the extra selectors, or you'll have to update your HTML to use the t-button class.

If it's only two properties though, it would be simple enough to just add the styles again. It's not ideal, and it means duplicating styles (which is against the point of CSS), but needs must.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.