Tuesday, November 18, 2014

CSS translate child when parent is hovered

<style type="text/css">

.slidebutton {
display:inline-block;
text-align:center;
padding:16px 30px;
font-family: verdana;
font-size: 25px;
border:1px solid #33b5e5;
position:relative;
cursor:pointer;
}

.slidebutton>.background {
position:absolute;
top:100%;
left:0%;
width:100%;
height:100%;
background-color:#33b5e5;
-webkit-transition: 0.2s ease-in-out;
-moz-transition: 0.2s ease-in-out;
-o-transition: 0.2s ease-in-out;
transition: 0.2s ease-in-out;
}

.slidebutton:hover>.background {
-webkit-transform: translate(0%,-100%);
-moz-transform: translate(0%,-100%);
-o-transform: translate(0%,-100%);
-ms-transform: translate(0%,-100%);
transform: translate(0%,-100%);
}

</style>

<div class="slidebutton">
    <div class="background"></div>
    <div class="text">MaHi</div>
</div>


Output :)

1)

2)

No comments:

Post a Comment