What's the support for .className.andClassName

2019-08-30 17:36发布

问题:

Confusing title? Sure!

In CSS, you can specify:

.button.blue {
    ...
}

Which will target elements that have both class names.

Does anyone know what the browser support is?

回答1:

I've never seen chaining of modifiers fail. I think you're good to go in all browsers still in use today, if not all browsers that ever implemented CSS.

EDIT: Nope. Just watched IE6 choke on it. Plugged this example into Adobe Browserlab, and both the class attributes hello world and world respond to the .hello.world selectors.

Booooo, IE6. IE7 is good to go on that point, though.

Here's a blog post describing the issue (IE just reads the last class, it would seem), and offering the following stupid but necessary fix if IE6 is required: <p class="one two one-two">