Here is my idea
.slidingbar-wrapper{
width: 100%;
line-height: 50px;
overflow: hidden;
}
.slidingbar{
margin-left: auto;
margin-right: auto;
width: 50px;
height: 50px;
transition: width 2s;
-webkit-transition: width 2s;
background-color: aquamarine;
z-index: auto;
position: relative;
}
.slidingbar:before, .slidingbar:after {
content: "";
background-color: white;
top: 0px;
width: 1000px;
bottom: 0px;
position: absolute;
z-index: 9;
}
.slidingbar:before {
right: 100%;
}
.slidingbar:after {
left: 100%;
}
.slidingbar-contentleft{
margin: 0px;
white-space: nowrap;
float:left;
z-index: 1;
position: relative;
}
.slidingbar-contentright{
margin: 0px;
white-space: nowrap;
float: right;
z-index: 1;
position: relative;
}
.slidingbar:hover{
width: 100%;
}
I set two pseudo elements on the sides of slidingbar. and set those to a higher z-index than the left and right content.
when slidebar gets wider, pushes those elements. And it's z-index is lower, so it gets "under" them, making them visible.