gpt4 book ai didi

html - 悬停某个图像时显示某些信息

转载 作者:太空宇宙 更新时间:2023-11-04 09:58:30 25 4
gpt4 key购买 nike

我有以下 css 和 HTML:

<div class="container">
<img class="imag one" src="http://homeinspectioncarync.com/wp-content/uploads/2016/05/glenn-e1464714419457.jpg">
<img class="imag two" src="http://homeinspectioncarync.com/wp-content/uploads/2016/05/Dave-974x1024.jpg">
<p class="name glenn">Glenn</p>
<p class="title glenn">Part Owner/Senior Inspector</p>
<p class="bio glenn">I am Glenn hear me roar!</p></img>
<p class="name dave">Dave</p>
<p class="title dave">Part Owner/ Manager</p>
<p class="bio dave">I am Dave hear me roar!</p>
</div>

.container {
height: 500px;
width: 100%;
border: 2px solid black;
}

.imag {
height: 100px;
width: 100px;
float: left;
}

.name {
position: absolute;
top: 50vh;
}

.title {
position: absolute;
top: 50vh;
left: 25vw;
}

.bio {
position: absolute;
top: 50vh;
left: 50vw;
}

.glenn {
opacity: 0;
}

.dave {
opacity: 0;
}

.one:hover .glenn {
opacity: 1 !important;
}

.one:hover {
opacity: 0.5;
}

我希望当将 glenn 的图像 (.one) 悬停时,所有带有 glenn 类的东西都应该出现,而当悬停 dave 的图片 (.two) 时,所有带有 .dave 的东西都应该出现。我如何使用此配置执行此操作?

最佳答案

您正在寻找 ~General sibling combinator选择器

<div class="container"> <img class="imag one" src="http://homeinspectioncarync.com/wp-content/uploads/2016/05/glenn-e1464714419457.jpg"> <img class="imag two" src="http://homeinspectioncarync.com/wp-content/uploads/2016/05/Dave-974x1024.jpg"> <p class="name glenn">Glenn</p> <p class="title glenn">Part Owner/Senior Inspector</p> <p class="bio glenn">I am Glenn hear me roar!</p></img> <p class="name dave">Dave</p> <p class="title dave">Part Owner/ Manager</p> <p class="bio dave">I am Dave hear me roar!</p> </div> .container {
height: 500px;
width: 100%;
border: 2px solid black;
}
.imag {
height: 100px;
width: 100px;
float: left;
}
.name {
position: absolute;
top: 50vh;
}
.title {
position: absolute;
top: 50vh;
left: 25vw;
}
.bio {
position: absolute;
top: 50vh;
left: 50vw;
}
.glenn {
opacity: 0;
}
.dave {
opacity: 0;
}
.one:hover ~ .glenn {
opacity: 1 !important;
}
.one:hover {
opacity: 0.5;
}
.two:hover ~ .dave {
opacity: 1 !important;
}
.two:hover {
opacity: 0.5;
}
<div class="container">
<img class="imag one" src="http://homeinspectioncarync.com/wp-content/uploads/2016/05/glenn-e1464714419457.jpg">
<img class="imag two" src="http://homeinspectioncarync.com/wp-content/uploads/2016/05/Dave-974x1024.jpg">
<p class="name glenn">Glenn</p>
<p class="title glenn">Part Owner/Senior Inspector</p>
<p class="bio glenn">I am Glenn hear me roar!</p>
<p class="name dave">Dave</p>
<p class="title dave">Part Owner/ Manager</p>
<p class="bio dave">I am Dave hear me roar!</p>
</div>

关于html - 悬停某个图像时显示某些信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38513405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com