2011-11-10 2 views
0

は、私は次のCSSの設定があります。そこで<DT>背景色を無効にしてシミュレーションを無効にするにはどうすればよいですか?

.dropdown dt { background:#e4dfcb !important; } 
.dropdown-disabled { background:#dddddd important; color:#aaaaaa; } 

だから私のhtmlコードで、私は意図的に入れ、ドロップダウン・無効のクラス、背景色の上書きを強制する必要があります...しかし、起きていません。

<dt id="dtTestID" class="dropdown-disabled"> 
    <a href="#"><span>Hello World</span></a> 
</dt> 

私は間違っていますか?うわ...

EDIT:

[OK]を、私は次のようにコードを更新しました:

.dropdown-enabled { background:#e4dfcb; } 
.dropdown-disabled { background:#dddddd; } 

.dropdown dt { background:#e4dfcb !important url(arrow.png) no-repeat scroll right center; } 
.dropdown dt a { display:block; padding-right:20px; border:1px solid #d4ca9a; width:150px;} 
.dropdown dt a:hover { color:#ffffff; border: 1px solid #d0c9af;} 
.dropdown dt a span { color:#816c5b; cursor:pointer; display:block; padding:5px; } 
.dropdown dt a span:hover { color:#ffffff; cursor:pointer; display:block; } 

<dt id="dtTestID" class="dropdown-disabled"><a href="#"><span>Hello World</span></a></dt> 

これは、バックグラウンドで動作し、私は他のどこでもドロップダウン対応を配置する必要があります。しかし、私は別の(同様の)問題に遭遇しました。リンクのスタイルをオーバーライドすることはできません。私は以下を試しました...

色を!importantに上書きし、私の無効を新しい色に設定しました。

.dropdown dt a span {color:#816c5b!important;カーソル:ポインタ;表示ブロック;パディング:5px; } .dropdown-disabled {背景:#dddddd;色:#aaaaaa; }

答えて

0

... 私は次のように私のCSSを更新し、その後、私のDTからリンクを削除する必要がありました。その後

.dropdown-enabled { background:#e4dfcb; } 
.dropdown-disabled span { background:#dddddd; color:#aaaaaa; } 

を私は他の上でマウスのクリックを監視するためにjQueryのを使用する必要があります要素を手動で有効にする...を切り替え、リンクを元に戻します。

var dt = jQ(this).find("dt"); 
// put back the look of enabled the element 
dt.removeClass("dropdown-disabled"); 
dt.addClass("dropdown-enabled"); 

// put back the link in there to trigger the dropdown 
var newhtml = jQ('<a href="#"></a>').append(dt.html()); 
dt.html(newhtml); 
1

CSSにimportant修飾語はありません。ちょうど!importantです。 試してみてください:

.dropdown dt { background:#e4dfcb } 
.dropdown-disabled { background:#dddddd !important; color:#aaaaaa; } 

希望します。周りの仕事を見つけ

+0

私はバックグラウンドで働いていましたが、リンクのスタイルに似た別の問題に直面しています...私は上記の質問を更新しました。 – codenamezero

関連する問題