Invert height direction in CSS

Yashar Shahmiri picture Yashar Shahmiri · Dec 12, 2014 · Viewed 22.5k times · Source

I want to change the height growth path of Top-down to Down-top Is it possible in CSS? this is my code
http://jsfiddle.net/yasharshahmiri/1pkemq1p/3/

        .buttom{
margin-top:200px;
margin-right:34px;
width:150px;
height:45px;
background:black;
float:right;
transition-duration:2s;  }
    .buttom:hover{
        height:180px;
        transition-duration:2s;}

Answer

Gildas.Tambo picture Gildas.Tambo · Dec 12, 2014

All you need is to set position: absolute and bottom position like this:

.buttom{
    margin-top:200px;
    margin-right:34px;
    width:150px;
    height:45px;
    background:black;
    float:right;
    position:absolute;
    bottom: 10px;
    transition: height 2s ease-in-out  
}
.buttom:hover{
    height:180px
}
                       <div class='buttom'> </div>

Use Rotate and transform-origin to be able to set position relative to the element

.buttom{
    margin-top:200px; /* this shall be higher than the height on hover*/
    margin-right:34px;
    width:150px;
    height:45px;
    background:black;
    transition: height 2s ease-in-out ;
    transform: rotatex(180deg);
    transform-origin: top;
}
.buttom:hover{
    height:180px
}
                       
<div class='buttom'> </div>

Or this way:

.buttom{
    width:150px;
    height:45px;
    background:black;
    transition: height .3s cubic-bezier(0.175, 0.885, 0.32, 1.275) ;
    transform: rotatex(180deg) translate3d(0, -200px,0);/* the Y-Value shall be higher than the height on hover*/
    transform-origin: top;
}
.buttom:hover{
    height:180px
}
    
<div class='buttom'></div>