CSS: styling when element has two classes
I have been looking at the w3 page on css selectors and have not found any promising leads, so I thought I would ask...
Is there a way to style a single element with two classes differently than 开发者_如何学运维if it was one class?
Example:
<a class="foo">Red</a>
<a class="bar">Yellow</a>
<a class="foo bar">Orange</a>
a.foo { color:red; }
a.bar { color:yellow; }
a.foo.bar { color:orange; }
You just answered yourself. Be wary of the IE6 bug.
Yeah dude, you have just answered it yourself. Have a quick scan on these two pages -
- http://webdesign.about.com/od/css/qt/tipcssmulticlas.htm
- http://www.maxdesign.com.au/articles/multiple-classes/
Hope that helps :)
Nick
I just tried the code you put up, and it works fine (on Chrome at least). Maybe there is a mistake in your CSS elsewhere, or some other style is overriding it.
精彩评论