I have a div with a border and i used keyframes to expand it onload but I want it to expand from the center rather than left to right.
http://andylilien.com/index2015.html
the css:
.navback {
position:absolute;
bottom:0px;
padding-bottom:-8px;
width:100%;
height:17px;
background-color:#FFF;
border-top: 1px solid #d0d0d0;
z-index:999;
}
@-webkit-keyframes expandline{
0%{width:0%;}
50%{width:50%;}
100%{width:100%;}
}
.navback{
-webkit-animation:expandline 2s;
}
Adjust the height and width as you are doing, but
transform
the element by positioning its left and top appropriately.Also, you don't really need keyframe animations for this if you're using a common easing function or linear animation.
What's happening with the CSS:
The expanding from center behavior is the result of:
Since we don't animate the
transform
, it continues to apply as defined in the initial rule: keep#expander
vertically and horizontally centered in its parent, regardless of how tall or wide it is.Now you just use whatever trigger is appropriate (you said you were using
onload
) to apply the expanded class and trigger the transition.Hope this helps.