I am creating a split screen page in Squarespace and I am having trouble trying to affect a sibling element. When I hover over one side, I want that one to grow and the other to shrink. I can get the left side to work, however when I hover over the right side, the left does not shrink.
I have tried to use ~ and it works, but only for one side.
.Main-content {
padding: 0;
margin: 0;
width: 100vw;
height: 100vh;
overflow-x: hidden;
}
.containerSplit {
position: relative;
width: 100vw;
height: 100vh;
background: #333 !important;
}
.split {
position: absolute;
width: 50vw;
height: 100vh;
overflow: hidden;
}
.split.leftSide {
left: 0;
background-color: red;
background-size: cover;
}
.split.leftSide:hover {
position: absolute;
content: "";
width: 75vw;
height: 100vh;
background-color: red;
z-index: 2;
}
**.split.leftSide:hover~.rightSide,
.split.rightSide:hover~.leftSide {
width: 25vw;
}
** .split.rightSide {
right: 0;
background-color: blue;
background-size: cover;
}
.split.rightSide:hover {
position: absolute;
content: "";
width: 75vw;
height: 100vh;
background-color: blue;
z-index: 2;
}
.split.leftSide,
.split.rightSide,
.split.rightSide:before,
.split.leftSide:before {
transition: 1000ms all ease-in-out;
}
<div class="containerSplit">
<div class="split leftSide">
<h1>The Designer</h1>
<a href="#" class="button">Read More</a>
</div>
<div class="split rightSide">
<h1>The Programmer</h1>
<a href="#" class="button">Read More</a>
</div>
</div>
I want the sibling element to shrink to 25vw when I hover over another element.