css3 をサポートしないブラウザー用の代替スタイルを作成するために modernizr を使用しています。それはうまく機能しますが、複数の css3 スタイルを使用する css クラスのソリューションは見つかりませんでした。
例 1:
div.button {
box-shadow: inset 1px 1px 2px #ccc; /* first css3 style */
border-radius: 5px; /* second css3 style */
}
/* fallback for browsers that don't support css3 */
.no-borderradius div.button {
background: transparent url(my-button.png) left top;
}
ここでの問題は、ブラウザが box-shadow をサポートしていても、border-radius をサポートしていない場合に問題が発生することです。この場合、両方のボタンが box-shadow を使用し、border-radiusを無視し、no-borderradius クラスを背景画像に適用します。2 つのフォールバックを作成することで解決できました。
例 2:
div.button {
box-shadow: inset 1px 1px 2px #ccc; /* first css3 style */
border-radius: 5px; /* second css3 style */
}
/* fallback for browsers that don't support css3 */
.no-borderradius div.button, .no-boxshadow div.button /* no-boxshadow added */ {
background: transparent url(my-button.png) left top;
}
ここでの問題は、ブラウザーが border-radiusとbox-shadow をサポートしていない場合、要素のスタイル設定に両方のクラスが使用されることです。