<div class="content-wrapper">
<div class="button --button-left is-rotated" data="is-light"><span>Off</span>
<div class="button-face-bottom"></div>
</div>
<div class="button --button-right" data="is-dark"><span>On</span>
<div class="button-face-bottom"></div>
</div>
</div>
$color1: #0B1821;
$color2: #FCE7B2;
$color1_light: lighten($color1, 5%);
$color2_light: lighten($color2, 5%);
$color5: rgba(109, 97, 100, 1);
$color_success: #23C057;
$color_text: rgba(black,.75);
$color_text_light: rgba(lighten($color5,15%),.75);
$color_bg: #C8D9E7;
$color_border: rgba(lighten($color1,50%),1);
@import url( 'https://fonts.googleapis.com/css?family=Rufina|Open+Sans:400,700');
body,
html {
width: 100%;
height: 100%;
margin: 0;
font-family: "Open Sans";
color: $color_text;
background-color: $color2;
overflow: hidden;
font-size: 1em;
font-style: normal;
-webkit-appearance: none;
outline: none;
text-rendering: geometricPrecision;
perspective: 1000px;
transition: all 0.4s ease-in-out;
&.is-light {
background-color: lighten($color2, 5%);
}
&.is-dark {
background-color: lighten($color1, 5%);
}
}
.content-wrapper {
width: 350px;
height: 100px;
border-radius: 5px;
position: absolute;
//background-color: rgb(250,250,250);
top: 50%;
left: 50%;
transform: translate(-50%,-50%) rotateX(0deg) rotateZ(0deg);
transition: all 0.395s ease-in-out;
padding: 0;
box-sizing: border-box;
line-height: 30px;
font-size: 14px;
display: flex;
transform-style: preserve-3d;
}
.button {
font-weight: 700;
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.5em;
text-transform: uppercase;
background-color: white;
transform-style: preserve-3d;
//box-shadow: 0 0 4px 0 rgba(black, .75);
position: relative;
cursor: pointer;
transform-style: preserve-3d;
transition: all 0.4s ease;
border: solid 1px rgba(black, .25);
box-sizing: border-box;
span {
transition: all 0.4s ease;
}
&.--button-left {
transform-origin: right;
background-color: $color1;
color: white;
&.is-rotated {
transform: rotateY(35deg);
span {
text-shadow: 0 0 4px rgba($color2, .5);
}
.button-face-bottom {
transform: rotateY(90deg) scaleY(1.08) translateX(78px) translateZ(0px);
}
}
.button-face-bottom {
height: 100%;
width: 50px;
position: absolute;
background: lighten($color1,10%);
top: 0;
left: 0;
border: solid 1px rgba(black, .5);
box-sizing: border-box;
transition: all 0.4s ease;
transform: rotateY(90deg) translateX(30px) translateZ(-20px);
}
}
&.--button-right {
transform-origin: left;
background-color: $color2;
&.is-rotated {
transform: rotateY(-35deg);
span {
text-shadow: 0 0 4px rgba($color1, .5);
}
.button-face-bottom {
transform: rotateY(100deg) scaleY(1.13) translateX(108px) translateZ(0px);
}
}
.button-face-bottom {
height: 100%;
width: 50px;
position: absolute;
background: darken($color2,40%);
top: 0;
right: 0;
border: solid 1px rgba(black, .25);
box-sizing: border-box;
transition: all 0.4s ease;
transform: rotateY(90deg) translateX(30px) translateZ(20px);
}
}
}
View Compiled
$(".button").click(function (e) {
if ($(this).hasClass("is-rotated")) {
$(".button").addClass("is-rotated");
$(this).removeClass("is-rotated");
}
$("body").removeClass();
$("body").addClass($(".button.is-rotated").attr("data"));
});
This Pen doesn't use any external CSS resources.