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

    2. <small id='Ocz3v'></small><noframes id='Ocz3v'>

      1. <i id='Ocz3v'><tr id='Ocz3v'><dt id='Ocz3v'><q id='Ocz3v'><span id='Ocz3v'><b id='Ocz3v'><form id='Ocz3v'><ins id='Ocz3v'></ins><ul id='Ocz3v'></ul><sub id='Ocz3v'></sub></form><legend id='Ocz3v'></legend><bdo id='Ocz3v'><pre id='Ocz3v'><center id='Ocz3v'></center></pre></bdo></b><th id='Ocz3v'></th></span></q></dt></tr></i><div id='Ocz3v'><tfoot id='Ocz3v'></tfoot><dl id='Ocz3v'><fieldset id='Ocz3v'></fieldset></dl></div>
      2. 如何应用 child:hover 但不是 parent:hover

        How to apply child:hover but not parent:hover(如何应用 child:hover 但不是 parent:hover)

            <legend id='z2xCd'><style id='z2xCd'><dir id='z2xCd'><q id='z2xCd'></q></dir></style></legend>

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

            <tfoot id='z2xCd'></tfoot>
              <tbody id='z2xCd'></tbody>

                <bdo id='z2xCd'></bdo><ul id='z2xCd'></ul>
                1. <i id='z2xCd'><tr id='z2xCd'><dt id='z2xCd'><q id='z2xCd'><span id='z2xCd'><b id='z2xCd'><form id='z2xCd'><ins id='z2xCd'></ins><ul id='z2xCd'></ul><sub id='z2xCd'></sub></form><legend id='z2xCd'></legend><bdo id='z2xCd'><pre id='z2xCd'><center id='z2xCd'></center></pre></bdo></b><th id='z2xCd'></th></span></q></dt></tr></i><div id='z2xCd'><tfoot id='z2xCd'></tfoot><dl id='z2xCd'><fieldset id='z2xCd'></fieldset></dl></div>
                  本文介绍了如何应用 child:hover 但不是 parent:hover的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用以下 html,当我将鼠标悬停在子项上时,我会在父项上获得绿色背景.我怎样才能阻止这种情况发生?如果我悬停在子元素之外,我确实想要绿色背景.

                  With the following html, when I hover over child, I get a green background on parent. How can I stop that from happening? I do want the green background if I am hovering outside of the child element.

                  CSS3 很好.

                  .parent {
                    padding: 100px;
                    width: 400px;
                    height: 400px;
                  }
                  
                  .parent:hover {
                    background-color: green;
                  }
                  
                  .child {
                    padding: 100px;
                    width: 200px;
                    height: 200px;
                  }
                  
                  .child:hover {
                    background-color: blue;
                  }

                  <div class="parent">
                    <div class="child">Child</div>
                  </div>

                  推荐答案

                  所以这真的很难看,但它确实有效(有点).我基本上是在创建父母的副本作为孩子的兄弟姐妹.parent-overwrite 默认隐藏,然后在 child 悬停时显示.Chrome 不喜欢它,除非您使用 + 选择器而不是 ~ 选择器.这不是很可扩展,但它可能会起作用.

                  So this is REALLY ugly, but it works (kind of). I'm basically creating a duplicate of parent as a sibling of child. parent-overwrite is hidden by default, then displayed on the hover of child. Chrome doesn't like it unless you use the + selector instead of the ~ selector. This isn't very scalable, but it may work.

                  正如其他人所说,javascript 可能是更好的解决方案.

                  As the other guys posted, javascript would likely be a better solution.

                   <style>
                    .parent { padding: 100px; width: 400px; height:400px; position: relative; z-index: 998; }
                    .parent:hover { background-color: green; }
                    .child { padding: 100px; width: 200px; height:200px; position: relative; z-index: 1000; }
                    .child:hover { background-color: blue; }
                    .parent-overwrite { padding: inherit; width: inherit; height: inherit; position: absolute; top: 0; left: 0; z-index: 999; background-color: #FFF; display: none; }
                    .child:hover ~ .parent-overwrite { display: block; }
                  </style>
                  
                  <div class="parent">
                      <div class="child">Child</div>
                      <div class="parent-overwrite"></div>
                  </div>

                  这篇关于如何应用 child:hover 但不是 parent:hover的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ChartJS Version 3 - common legend for multiple line charts(ChartJS 版本 3 - 多个折线图的常用图例)
                  Chart.js yAxes Ticks stepSize not working (fiddle)(Chart.js yAxes Ticks stepSize 不起作用(小提琴))
                  ChartJS - Finding the minimum and maximum labels that are inside a pan (When zooming)(ChartJS - 查找平底锅内的最小和最大标签(缩放时))
                  Chart.js - Color specific parts of the background in a line chart(Chart.js - 在折线图中为背景的特定部分着色)
                  chart.js bar chart change color based on value(chart.js 条形图根据值改变颜色)
                  How to apply gradient color in chart.js?(如何在 chart.js 中应用渐变颜色?)
                      • <bdo id='9OQtx'></bdo><ul id='9OQtx'></ul>
                          <tbody id='9OQtx'></tbody>
                        <legend id='9OQtx'><style id='9OQtx'><dir id='9OQtx'><q id='9OQtx'></q></dir></style></legend>

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

                            <small id='9OQtx'></small><noframes id='9OQtx'>