<div class="container">
<div class="left-bg">
</div>
<div class="right-bg">
</div>
</div>
/* A tweak of an original pen by Dylan Yee
https://codepen.io/dylanyee/pen/Hjqxy?limit=all&page=6&q=css+background
*/
@import "bourbon";
html {
font-family: sans-serif;
font-size: 13px;
}
.container {
position: relative;
background: #f1f1f1;
margin: 40px auto;
width: 80%;
height: 360px;
}
.left-bg, .right-bg {
position: absolute;
top: 0;
bottom: 0;
width: 50%;
transition: .25s ease;
}
.left-bg {
background-color:#24800f;
left: 0;
}
.right-bg {
background-color:#5988ad;
background-position: right;
right: 0;
}
.right-bg:before {
content: "OR";
font-weight: bold;
position: absolute;
background: white;
text-align: center;
width: 30px;
height: 30px;
line-height: 30px;
border-radius: 15px;
top: 150px;
left: 0;
-webkit-transform: translate(-50%, -50%);
}
.right-bg:after {
content: " ";
height: 280px;
width: 1px;
background-color: white;
display: block;
position: absolute;
left: 0;
right: 0;
top: 20px;
}
.right-bg:after {
right: 0;
}
.left-bg:hover {
width: 60%;
}
.left-bg:hover + .right-bg {
width: 40%;
}
.right-bg:hover {
width: 60%;
}
.right-bg:hover + .left-bg {
width: 40%;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.