hover事件,鼠标移入一个标签使其子级标签的css样式发生改变

目标:鼠标移入一个标签使其子级标签显示可见。

html代码:

<div class="father">鼠标移入显示

   <p class="child">隐藏内容,经过鼠标移入后展示。</p>

</div>

css代码:

.father .child{

     display:none;   //p的内容一开始设置为不可见

}

.father:hover .child{

     display:block;    //鼠标移入后,p的标签的内容为可见

}

这里有一点要注意,要显示的内容必须存在于其父级标签(即div标签)的子集标签(即p标签)中,否则无法生效。

转载自:https://blog.csdn.net/sinat_34349564/article/details/52045865


猜你喜欢

转载自blog.csdn.net/huanghanqian/article/details/80720979