[英]targeting 2nd child in css hover
HTML snippet HTML片段
<a href="<?php the_permalink(); ?>" class="linkage"></a>
<div class="test"><h1>test</h1></div>
<div class="cover"></div>
CSS CSS
.linkage, .cover {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
.linkage { z-index: 10; }
.cover {
background-color: rgba(0, 0, 0, 0);
transition: background-color 0.35s ease;
}
.test {
position: absolute;
z-index: 9;
margin: 0 50%;
opacity:0;
transition: opacity 0.5s ease;
}
.linkage:hover + .test {
opacity:1;
transition-delay:0s;
}
linkage takes up the full size of the space. 连接占据了整个空间的大小。 It creates a hyperlink over the whole area (z-sexed to the top so that hovering over other elements doesn't disrupt the link)
它在整个区域上创建一个超链接(z-sexed到顶部,以便悬停在其他元素上不会破坏链接)
hovering over 'linkage' make the opacity of 'test' visible. 将鼠标悬停在“链接”上会使“测试”的不透明度变得可见。 I want it also to make the visibility of 'cover' visible as well, but I can't seem to target it (since it's not i direct child or adjacent to 'linkage')
我也希望它也可以使'封面'的可见性也可见,但我似乎无法定位它(因为它不是我直接的孩子或与'连接'相邻)
You can use next all siblings 你可以使用下一个兄弟姐妹
.linkage:hover ~ .cover{
}
or 要么
.linkage:hover + .test + .cover{
}
This will solve your problem: 这将解决您的问题:
.linkage:hover + .test, .linkage:hover ~ .cover {
opacity:1;
transition-delay:0s;
}
In general, 一般来说,
element+element 元件+元件
eg div + p 例如 div + p
Explaination: Selects all 'p' elements that are placed immediately after 'div' elements 解释:选择紧跟在'div'元素之后的所有'p'元素
element1~element2 部件1〜element2的
eg p ~ ul 例如 p~ul
Explaination: Selects every 'ul' element that are preceded by a 'p' element 解释:选择前面带有'p'元素的每个'ul'元素
Visit, Here for more information about various selectors. 访问, 这里有关各种选择器的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.