Change Css Element That Comes After Another
I would like to hover in a.bio change the background .pic to green. I tried some ways, but it did not work out. I did not understand the logic of ~ and how even to make it work.
Solution 1:
Move your a.bio
in your HTML, because ~
is a sibling selector (however less strict than the +
), and use position
to stay as it was before moving the HTML:
Snippet
.executivo.pic::after {
background-color: #00845b;
content: "";
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
opacity: 0;
transition: .3s ease-in-out;
}
.executivo {
position: relative;
}
.executivoa.bio {
position: absolute;
bottom: -20px
}
.executivoa.bio:hover ~ .picimg {
opacity: 0.35;
}
.executivo.pic {
margin-bottom: 45px;
position: relative;
}
.executivo.picimg {
display: block;
max-width:100%/*demo*/
}
<divclass="executivo"><aclass="bio"href="#">Bio+</a><divclass="pic"><imgsrc="//lorempixel.com/1600/900"alt="alt text" /></div><divclass="title"><h3>title</h3></div></div>
Post a Comment for "Change Css Element That Comes After Another"