Masz gotowca:
<!DOCTYPE html>
<html lang="pl">
<head>
<title></title>
<meta charset="utf-8">
<style>
.socBox {
border: 1px solid red;
height: 400px;
width: 300px;
position: fixed;
transition: 1s all ease-in-out;
}
.socBoxButton {
transform: rotate(90deg);
transform-origin: left top;
}
socBoxHide {
right: 0px !impoortant;
}
.socBox:first-child {
top: 100px;
background-color: red;
width: 400px;
right: -402px;
}
.socBox:nth-child(2) {
top: 170px;
background-color: blue;
right: -302px;
}
.socBox:nth-child(3) {
top: 240px;
background-color: green;
width: 500px;
right: -502px;
}
</style>
</head>
<body>
<div class="socBox">
<button type="button" class="socBoxButton">Przycisk</button>
</div>
<div class="socBox">
<button type="button" class="socBoxButton">Przycisk</button>
</div>
<div class="socBox">
<button type="button" class="socBoxButton">Przycisk</button>
</div>
<script>
var elements = document.getElementsByClassName('socBox'),
elementsLength=elements.length,
i;
for(i = 0; i < elementsLength; i++) {
elements[i].addEventListener('click', function(){
if(this.style.right != '1px') {
this.style.right= '1px';
} else {
this.style.right= this.offsetWidth * -1 +'px';
}
}, false);
}
</script>
</body>
</html>