我想在将鼠标悬停在父级上时触发子级div。搜索了许多主题,但没有找到真正有用的,除了: class.parent:hover class.child {}
我的主题不重复: css 悬停子项以触发对父项的影响
提供的资料来源:https://jsfiddle.net/Arty_Prof/81e4uy3w/
html {
background: black;
}
#buttonStart {
position: absolute;
width: 15%;
height: 10%;
bottom: 15%;
left: 5%;
}
#imageStart {
width: 100%;
height: 100%;
}
#buttonStart:hover .hovicon.effect-3.sub-b {
cursor: pointer;
}
.hovicon {
display: inline-block;
font-size: 45px;
line-height: 90px;
cursor: pointer;
width: 90px;
height: 90px;
border-radius: 50%;
text-align: center;
position: relative;
text-decoration: none;
z-index: 1;
color: #fff;
}
.hovicon.auto-width {
width: auto;
height: auto;
}
.hovicon:after {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
content:'';
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.hovicon:before {
speak: none;
font-size: 48px;
line-height: 90px;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
display: block;
-webkit-font-smoothing: antialiased;
}
.hovicon.effect-3 {
position: absolute;
bottom:-13%;
left: 62%;
font-size: 3.8em;
-webkit-transition: color 0.3s;
-moz-transition: color 0.3s;
transition: color 0.3s;
}
.hovicon.effect-3:after {
top: -2px;
left: -2px;
padding: 2px;
z-index: -1;
background: #fff;
-webkit-transition: -webkit-transform 0.2s, opacity 0.3s;
-moz-transition: -moz-transform 0.2s, opacity 0.3s;
transition: transform 0.2s, opacity 0.3s;
}
/* Effect 3b */
.hovicon.effect-3.sub-b, .hovicon.effect-3.sub-b i {
color: #fff;
}
.hovicon.effect-3.sub-b:hover, .hovicon.effect-3.sub-b:hover i {
color: #696969;
}
.hovicon.effect-3.sub-b:after {
-webkit-transform: scale(1.3);
-moz-transform: scale(1.3);
-ms-transform: scale(1.3);
transform: scale(1.3);
opacity: 0;
}
.hovicon.effect-3.sub-b:hover:after {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
<div id="buttonStart">
<div><input type="image" id="imageStart" src="https://cdn.pixabay.com/photo/2017/10/10/07/48/beach-2836300_960_720.jpg">
<div class="hovicon effect-3 sub-b" id="buttonStartEffect">   </div>
</div>
</div>
小提琴中的其他代码。
我希望在悬停父div时看到白色圆圈(在我的例子中是图片(。
你的小提琴几乎是正确的。我刚刚更改了最后一个选择器,如下所示,它在将鼠标悬停在父div 上时显示圆形动画。请尝试以下css
html {
background: black;
}
#buttonStart {
position: absolute;
width: 15%;
height: 10%;
bottom: 15%;
left: 5%;
}
#imageStart {
width: 100%;
height: 100%;
}
#buttonStart:hover .hovicon.effect-3.sub-b {
cursor: pointer;
}
/* Effect 3 */
.hovicon {
display: inline-block;
font-size: 45px;
line-height: 90px;
cursor: pointer;
width: 90px;
height: 90px;
border-radius: 50%;
text-align: center;
position: relative;
text-decoration: none;
z-index: 1;
color: #fff;
}
.hovicon.auto-width {
width: auto;
height: auto;
}
.hovicon:after {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
content: '';
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.hovicon:before {
speak: none;
font-size: 48px;
line-height: 90px;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
display: block;
-webkit-font-smoothing: antialiased;
}
.hovicon.effect-3 {
position: absolute;
bottom: -13%;
left: 62%;
font-size: 3.8em;
-webkit-transition: color 0.3s;
-moz-transition: color 0.3s;
transition: color 0.3s;
}
.hovicon.effect-3:after {
top: -2px;
left: -2px;
padding: 2px;
z-index: -1;
background: #fff;
-webkit-transition: -webkit-transform 0.2s, opacity 0.3s;
-moz-transition: -moz-transform 0.2s, opacity 0.3s;
transition: transform 0.2s, opacity 0.3s;
}
/* Effect 3b */
.hovicon.effect-3.sub-b,
.hovicon.effect-3.sub-b i {
color: #fff;
}
.hovicon.effect-3.sub-b:hover,
.hovicon.effect-3.sub-b:hover i {
color: #696969;
}
.hovicon.effect-3.sub-b:after {
-webkit-transform: scale(1.3);
-moz-transform: scale(1.3);
-ms-transform: scale(1.3);
transform: scale(1.3);
opacity: 0;
}
#buttonStart:hover .hovicon.effect-3.sub-b:after {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}