Hide the child element of a div on hover

試著忘記壹切 提交于 2019-12-13 13:25:08

问题


Is there a way to make this work. I want to hover over the outer div and hide a child element without using javascript. Is something like this possible?

.fullwrap:nth-child(1):hover { 
    display: none; 
}

回答1:


To hide a child element you need an structure like this:

#parent:hover .yourchild {
   display:none;
}

Where #parent is your outer div and has the :hover action, then you just match the child element to make it hide.

In this case I guess you have some structure like this:

<div class="fullwrap">
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
</div> 

Then to hide a child you can do some like this:

.fullwrap:hover :nth-child(1) { 
  display: none; 
}

Check this Demo http://jsfiddle.net/55TWN/



来源:https://stackoverflow.com/questions/21555519/hide-the-child-element-of-a-div-on-hover

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!