The way to affect another element on hovering on an element is apparently with a sibling selector, but I have a shape which is nested in a div to make it a triangle, from this thread: Hover and click on CSS triangle
I cant put my other element (the background image) in that div because it ruins it, but if I have it outside it, its not a sibling anymore.
<div class="sprite1"> </div>
<div class="box">
<div class="tria"> </div>
<!-- <div class="sprite1"> </div> -->
</div>
.sprite1 {
background: url('https://puppydogweb.com/gallery/puppies/beagle.jpg') no-repeat;
}
.sprite1 {
background-position: -43px -38px;
width: 304px;
height: 318px;
}
.sprite1:hover {
background-position: -43px -72px;
width: 304px;
height: 319px;
}
.box {
width: 40%;
padding-bottom: 28.2842712474619%; /* = width / sqrt(2) */
position: relative;
overflow: hidden;
}
.box .tria {
position: absolute;
top: 0; left: 0;
width: 100%; height: 100%;
background-color: rgba(0, 122, 199, 0.7);
transform-origin: 0 100%;
transform: rotate(45deg);
transition: background-color .3s;
}
.tria:hover {
background: rgba(255, 165, 0, 0.7);
}
.tria:hover ~ .sprite1 {
background-position: -84px -438px;
width: 122px;
height: 48px;
}
.tria:hover + .sprite1 {
background-position: -84px -438px;
width: 122px;
height: 48px;
}
.tria:hover > .sprite1 {
background-position: -84px -438px;
width: 122px;
height: 48px;
}
.tria:hover .sprite1 {
background-position: -84px -438px;
width: 122px;
height: 48px;
}
Fiddle: https://jsfiddle.net/csskg4t9/2/
Also I really dont want to use Javascript.
If anyone can direct me to a resource about css children and parents that would be appreciated. I dont know the terminology so its hard to look up.