Schneider
Schneider

Reputation: 2506

Adding CSS rule to some elements

I have css rule that goes like this

div#tabstrip.tabstrip-vertical.k-widget.k-header.k-tabstrip div#tabstrip-4.k-content.k-state-active{
    background-image: url("http://wwww.example.com/logo2.png") !important;
    background-position: right center;
    background-repeat: no-repeat;
}

The problem is with #tabstrip-4 i dont know how any numbers it will be and i want to apply that role to all that elements, only id of elements will be changed like 2 3 4 5 etc..

Any pseuso selector solution?

Upvotes: 1

Views: 45

Answers (2)

Sheepish
Sheepish

Reputation: 71

Use the "starts with" selector: div[id^='tabstrip-']

div#tabstrip.tabstrip-vertical.k-widget.k-header.k-tabstrip div[id^='tabstrip-'].k-content.k-state-active{
    background-image: url("http://wwww.example.com/logo2.png") !important;
    background-position: right center;
    background-repeat: no-repeat;
}

Upvotes: 1

Alex
Alex

Reputation: 7374

That's what classes are for. Put classes on just elements you want to style that way and add your CSS for the class. If this is, for some reason, not viable, you can always use the "starts-with" selector in CSS:

div[id^="tabstrip-"] {
   /* Your CSS*/
}

Upvotes: 3

Related Questions