こんにちは、別の div をホバーしながら div を表示する興味深い方法を見つけました。私はこの質問の受け入れられた答えからこの例に従っています:
スタックオーバーフローからの質問で、それは好きでした:
そのcssルールを作成しているときに問題が発生しました。問題は、私がそのような構造を持っていることです:
<div class="footer">
<div id="content">
<div id="list">
<span class="up">some text</span>
<ul class="nav">some content</ul>
<div class="flag">
<div id="<?php echo $variable;?>"></div>**---->here comes the variable that is neccessary for the css rule**
<div id="drop_down">the div that will displayed when hover flag</div>
</div><!--flag -->
</div><!--list -->
</div><!--content -->
</div><!--Footer -->
css ルールの構造は次のようになります。
.footer #content #list .flag > #$variable+#drop_down {
display: none;
}
.footer #content #list .flag > #$variable+#drop_down:first-child {
display: block;
}
.footer #content #list .flag:hover > #$variable+#drop_down {
display: block;
}
たとえば、htmlは次のようになります$variable
。a
<div class="flag">
<div id="a"></div>
div id="drop_down">some content</div>
</div><!--flag -->
そしてCSSルール:
.footer #content #list .flag > #a+#drop_down...
.footer #content #list .flag > #a+#drop_down:first-child...
.footer #content #list .flag:hover > #a+#drop_down...
しかし、たとえば、$variable
等しくない場合はどうなりますか?a
b
私は次のようなさまざまな方法を試しました:
.footer #content #list .flag > #a,#b+#drop_down...
.footer #content #list .flag > #a,#b+#drop_down:first-child...
.footer #content #list .flag:hover > #a,#b+#drop_down...
また
.footer #content #list .flag > #a+#b+#drop_down...
.footer #content #list .flag > #a+#b+#drop_down:first-child...
.footer #content #list .flag:hover > #a+#b+#drop_down...
また
.footer #content #list .flag > #a+#drop_down,
.footer #content #list .flag > #b+#drop_down,
...
.footer #content #list .flag > #a+#drop_down:first-child,
.footer #content #list .flag > #b+#drop_down:first-child,
...
.footer #content #list .flag:hover > #a+#drop_down,
.footer #content #list .flag:hover > #b+#drop_down...
しかし、これらのどれも機能しませんでした。
これを取得する方法を教えてくれる人がいれば、本当に感謝しています。
どうもありがとう。