• <small id='KK9aL'></small><noframes id='KK9aL'>

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

        悬停在子级上而对父级没有悬停效果

        hover on child without hover effect on parent(悬停在子级上而对父级没有悬停效果)
      1. <legend id='Cu82y'><style id='Cu82y'><dir id='Cu82y'><q id='Cu82y'></q></dir></style></legend>
            <bdo id='Cu82y'></bdo><ul id='Cu82y'></ul>
                <tbody id='Cu82y'></tbody>

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

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

                • <tfoot id='Cu82y'></tfoot>
                  本文介绍了悬停在子级上而对父级没有悬停效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我有 2 个 div,它们彼此相辅相成,就像这样

                  当我将鼠标悬停在 .parent 上时,我想从 .parent 更改 background.

                  但是当我将鼠标悬停在 .child 上时,我希望 background 再次恢复正常.

                  例如:(或 http://jsfiddle.net/k3Zdt/1/)

                  .parent {过渡:背景色 1s;宽度:100 像素;高度:100px;背景:#3D6AA2;填充:50px;}.父:悬停{背景:#FFF;}.孩子 {高度:100px;宽度:100 像素;背景:#355E95;过渡:背景色 1s;}.child:悬停{背景:#000;}

                  <div class="parent"><div 类="子"></div></div>

                  当我将鼠标悬停在深蓝色区域上时,我希望非深蓝色区域保持不那么深蓝色,而不是变为白色.

                  我想保留这个 <div> 结构.而且我不想要 JavaScript 解决方案(我知道 JavaScript 解决方案,但我想保持纯 CSS).

                  解决方案

                  基本上你不能:悬停子元素时如何设置父元素的样式?

                  但是一个技巧是使用兄弟元素:http://jsfiddle.net/k3Zdt/8/

                  .parent {宽度:100px;高度:100px;填充:50px;}.孩子 {高度:100px;宽度:100px;背景:#355E95;过渡:背景色 1s;位置:相对;顶部:-200 像素;}.child:悬停{背景:#000;}.兄弟姐妹{位置:相对;宽度:100px;高度:100px;填充:50px;顶部:-50 像素;左:-50px;背景:#3D6AA2;过渡:背景色 1s;}.兄弟:悬停{背景:#FFF;}

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

                  So I have 2 div's they're in each other so like this

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

                  and I want to change the background from .parent when I hover over .parent.

                  but I want the background to turn normal again when I hover over .child.

                  so for example: (or http://jsfiddle.net/k3Zdt/1/ )

                  .parent {
                      transition:background-color 1s;
                      width:100px;
                      height:100px;
                      background:#3D6AA2;
                      padding:50px;
                  }
                  
                  .parent:hover {
                      background:#FFF;
                  }
                  
                  .child {
                      height:100px;
                      width:100px;
                      background:#355E95;
                      transition:background-color 1s;
                  }
                  
                  .child:hover {
                      background:#000;
                  }

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

                  When I hover over the darkblue area I want the not-so-darkblue area to stay not-so-darkblue instead of changing to white.

                  I would like to keep this <div> structure. and I dont want a JavaScript solution (I know the JavaScript solution but I want to keep it pure CSS).

                  解决方案

                  Basically you can't : How to style the parent element when hovering a child element?

                  But a trick is to use a sibling element : http://jsfiddle.net/k3Zdt/8/

                  .parent {
                    width: 100px;
                    height: 100px;
                    padding: 50px;
                  }
                  
                  .child {
                    height: 100px;
                    width: 100px;
                    background: #355E95;
                    transition: background-color 1s;
                    position: relative;
                    top: -200px;
                  }
                  
                  .child:hover {
                    background: #000;
                  }
                  
                  .sibling {
                    position: relative;
                    width: 100px;
                    height: 100px;
                    padding: 50px;
                    top: -50px;
                    left: -50px;
                    background: #3D6AA2;
                    transition: background-color 1s;    
                  }
                  
                  .sibling:hover {
                    background: #FFF;
                  }

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

                  这篇关于悬停在子级上而对父级没有悬停效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='m13he'></bdo><ul id='m13he'></ul>
                        <i id='m13he'><tr id='m13he'><dt id='m13he'><q id='m13he'><span id='m13he'><b id='m13he'><form id='m13he'><ins id='m13he'></ins><ul id='m13he'></ul><sub id='m13he'></sub></form><legend id='m13he'></legend><bdo id='m13he'><pre id='m13he'><center id='m13he'></center></pre></bdo></b><th id='m13he'></th></span></q></dt></tr></i><div id='m13he'><tfoot id='m13he'></tfoot><dl id='m13he'><fieldset id='m13he'></fieldset></dl></div>
                        <legend id='m13he'><style id='m13he'><dir id='m13he'><q id='m13he'></q></dir></style></legend>
                        <tfoot id='m13he'></tfoot>

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

                              <tbody id='m13he'></tbody>