2

I have this CSS which targets all classes containing a - character.

[class*="-"] {
    background-color: rgba(86, 61, 124, 0.15);
    border: 1px solid rgba(86, 61, 124, 0.2);
    padding-bottom: 15px;
    padding-top: 15px;
    margin-bottom: 20px;
}

Is it possible to target all classes with a - character and a number afer it?

1
  • 7
    IMHO, if you're using CSS selectors to target all classes with a pattern, you're not using CSS correctly ;) Namely, all of those elements should share a class, which will be faster, easier to maintain, and less error-prone than pattern matching. Commented Jul 28, 2015 at 20:24

1 Answer 1

1

I believe the only way possible would be:

[class*="-0"],
[class*="-1"],
[class*="-2"],
[class*="-3"],
[class*="-4"],
[class*="-5"],
[class*="-6"],
[class*="-7"],
[class*="-8"],
[class*="-9"] {
    /*...*/
}

But I don't believe it's a wise selector. You should rethink your approach.

Sign up to request clarification or add additional context in comments.

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.