Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I animate this box to have a pop out effect?

I have a simple div set up and I was wondering how I could make it have a 'pop out' effect. For example, I would like it to start as a smaller rectangle and have it animate to a slightly larger rectangle giving it the illusion that it is popping out at you.

HTML

<div id="submit-logged-out">
    You must be <a href="/wp-login.php?action=register">registered</a> to submit.
</div>

CSS

#submit-logged-out {
background: #000;
color: #fff;
font-size: 2em;
left: 112px;
padding: 40px;
position: absolute;
top: 200px;
}

JSFiddle: http://jsfiddle.net/SSsVx/

like image 686
J82 Avatar asked Jan 26 '13 22:01

J82


People also ask

How do you delay animation in CSS?

CSS Animation Delay Syntax The CSS animation-delay property has the following syntax: animation-delay: [time] | initial | inherit; As you can see, there are three possible values: time, initial, and inherit. The first option is [time], which is the number of seconds or milliseconds before the animation starts.


1 Answers

This is best done with plain CSS:

.popout {
    animation: popout 1s ease;
    -webkit-animation: popout 1s ease;
}
@keyframes popout {
    from{transform:scale(0)}
    80%{transform:scale(1.2)}
    to{transform:scale(1)}
}
@-webkit-keyframes popout {
    from{-webkit-transform:scale(0)}
    80%{-webkit-transform:scale(1.2)}
    to{-webkit-transform:scale(1)}
}

Then just add the .popout class to your box.

Updated Fiddle

like image 119
Niet the Dark Absol Avatar answered Nov 09 '22 17:11

Niet the Dark Absol