<legend id='MnUch'><style id='MnUch'><dir id='MnUch'><q id='MnUch'></q></dir></style></legend>
  • <tfoot id='MnUch'></tfoot>

    <i id='MnUch'><tr id='MnUch'><dt id='MnUch'><q id='MnUch'><span id='MnUch'><b id='MnUch'><form id='MnUch'><ins id='MnUch'></ins><ul id='MnUch'></ul><sub id='MnUch'></sub></form><legend id='MnUch'></legend><bdo id='MnUch'><pre id='MnUch'><center id='MnUch'></center></pre></bdo></b><th id='MnUch'></th></span></q></dt></tr></i><div id='MnUch'><tfoot id='MnUch'></tfoot><dl id='MnUch'><fieldset id='MnUch'></fieldset></dl></div>

    <small id='MnUch'></small><noframes id='MnUch'>

      <bdo id='MnUch'></bdo><ul id='MnUch'></ul>

        CSS在悬停时从不同元素更改元素内容

        时间:2023-11-29
        <tfoot id='tcqTg'></tfoot>
        <legend id='tcqTg'><style id='tcqTg'><dir id='tcqTg'><q id='tcqTg'></q></dir></style></legend>

          <tbody id='tcqTg'></tbody>
            • <bdo id='tcqTg'></bdo><ul id='tcqTg'></ul>
            • <small id='tcqTg'></small><noframes id='tcqTg'>

                  <i id='tcqTg'><tr id='tcqTg'><dt id='tcqTg'><q id='tcqTg'><span id='tcqTg'><b id='tcqTg'><form id='tcqTg'><ins id='tcqTg'></ins><ul id='tcqTg'></ul><sub id='tcqTg'></sub></form><legend id='tcqTg'></legend><bdo id='tcqTg'><pre id='tcqTg'><center id='tcqTg'></center></pre></bdo></b><th id='tcqTg'></th></span></q></dt></tr></i><div id='tcqTg'><tfoot id='tcqTg'></tfoot><dl id='tcqTg'><fieldset id='tcqTg'></fieldset></dl></div>

                  本文介绍了CSS在悬停时从不同元素更改元素内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 CSS 中 是否可以在从不同元素悬停时更改元素的内容?例如,我有这个 div A、B、C、D、E、F.当我将鼠标悬停在 B 中时,我想在 A 中显示一些文本.如果我将鼠标悬停在 C 中,则会在 A 中显示不同的文本.其余的也是如此.将鼠标悬停在 B 到 F 中时,所有更改都发生在 A 中.

                  Is it possible in CSS to change an element's content when hovered from a different element? Let's say for example, I have this divs A, B, C, D, E, F. I want to show some text in A when I hover in B. a different text will appear in A if I hover over in C. and the same goes for the rest. All the changes takes place in A when hovered in divs B to F.

                  推荐答案

                  目前仅使用 CSS 是不可能的.您可以调整孩子或即将到来的兄弟姐妹的风格.但是您不能设置先前兄弟元素或父元素的样式.

                  Currently this is not possible with CSS only. You can adjust the styles of children or upcoming siblings. But you can't set the styles of previous siblings or parent elements.

                  所以关于你的情况,你可以这样做:

                  So regarding your case you could do:

                  <div class="a"></div>
                  <div class="b"></div>
                  <div class="c"></div>
                  

                  CSS

                  /* next sibling only */
                  div.a:hover + div.b { /* styles for b when hovering a */ }
                  
                  /* general sibling selector */
                  div.a:hover ~ div.c { /* styles for c when hovering a */ }
                  div.b:hover ~ div.c { /* styles for c when hovering b */ }
                  

                  你不能走另一条路,例如从 ba.

                  You can't go the other way, from b to a for example.

                  演示

                  先试后买

                  这篇关于CSS在悬停时从不同元素更改元素内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:有什么方法可以阻止 CSS :hover text-decoration underline on child? 下一篇:Firefox:悬停在元素上时如何停止和检查添加的新样式?

                  相关文章

                  1. <legend id='myRIi'><style id='myRIi'><dir id='myRIi'><q id='myRIi'></q></dir></style></legend>
                      <bdo id='myRIi'></bdo><ul id='myRIi'></ul>

                      <small id='myRIi'></small><noframes id='myRIi'>

                    1. <i id='myRIi'><tr id='myRIi'><dt id='myRIi'><q id='myRIi'><span id='myRIi'><b id='myRIi'><form id='myRIi'><ins id='myRIi'></ins><ul id='myRIi'></ul><sub id='myRIi'></sub></form><legend id='myRIi'></legend><bdo id='myRIi'><pre id='myRIi'><center id='myRIi'></center></pre></bdo></b><th id='myRIi'></th></span></q></dt></tr></i><div id='myRIi'><tfoot id='myRIi'></tfoot><dl id='myRIi'><fieldset id='myRIi'></fieldset></dl></div>
                      <tfoot id='myRIi'></tfoot>