I have a typing effect that I like, I want to use it for all my page titles, but the problem is it works by specifying a width. This would be fine for a homepage with a slogan, but if I ever decide to change it all of my width values would need to change too. Is there any way this can still function the same without being based on a width?
The example is what I'm using on my homepage, it's a slogan. But my title's would be single line text like: About, Contact, Support, News, etc.
My code looks like:
<div id="head">
<div class="wrap">
<div>
<p>We Create</p>
<p>Software for</p>
<p>People!!</p>
</div>
</div>
</div>
My CSS looks like:
#head {
background: #000;
height: 700px;
overflow: hidden;
position: relative;
}
#head .wrap {
height: 100%;
margin: 0 auto;
max-width: 850px;
position: relative;
width: 100%;
}
#head .wrap div {
align-items: center;
display: flex;
flex-direction: column;
letter-spacing: 2px;
height: 100%;
position: relative;
width: 100%;
}
#head .wrap div p {
border-right: 5px solid #b5cfd7;
color: #fff;
font-family: 'Montserrat', sans-serif;
font-size: 85px;
font-weight: 900;
margin-left: 10px;
overflow: hidden;
text-transform: uppercase;
white-space: nowrap;
}
#head .wrap div p:nth-child(1) {
animation: type 2s steps(20, end) 0s 1 normal forwards, blink .5s step-end 4s infinite alternate;
width: 575px;
}
#head .wrap div p:nth-child(2) {
animation: type2 2s steps(20, end) 2s 1 normal forwards, blink .5s step-end 4s infinite alternate;
opacity: 0;
width: 775px;
}
#head .wrap div p:nth-child(3) {
animation: type3 2s steps(20, end) 4s 1 normal forwards, blink .5s step-end 4s infinite alternate;
opacity: 0;
width: 475px;
}
/* Animation */
#keyframes type {
0% {
width: 0;
}
99.9% {
border-right: 5px solid #b5cfd7;
}
100% {
border: none;
}
}
/* Animation */
#keyframes type2 {
0% {
width: 0;
}
1% {
opacity: 1;
}
99.9% {
border-right: 5px solid #b5cfd7;
}
100% {
border: none;
opacity: 1;
}
}
/* Animation */
#keyframes type3 {
0% {
width: 0;
}
1% {
opacity: 1;
}
100% {
opacity: 1;
}
}
/* Animation */
#keyframes blink {
50% {
border-color: transparent;
}
}
Live Example: https://codepen.io/joshrodgers/pen/BaxxQzo
Any help is appreciated!
Thanks,
Josh
Ok...
So, I found a solution...it uses some JS, but that's the only way I could get it to work!
Here's how my code looks now:
<div id="head">
<div class="wrap">
<div class="row">
<div class="text">
<p>We create</p>
<p>Software for</p>
<p>People!!</p>
</div>
<div class="title"></div>
</div>
</div>
The CSS:
#head {
background: #000;
overflow: hidden;
position: relative;
}
#head .wrap {
display: flex;
flex: 1;
flex-direction: column;
height: 100%;
margin: 0 auto;
max-width: 850px;
position: relative;
text-align: center;
width: 100%;
}
#head .row {
align-items: center;
display: flex;
height: 100vh;
justify-content: center;
}
#head .text {
display: none;
}
#head .title {
position: relative;
z-index: 1;
}
#head .title span {
color: #fff;
display: block;
font-family: 'Montserrat', sans-serif;
font-size: 85px;
font-weight: 900;
letter-spacing: 2px;
height: 90px;
min-width: 5px;
text-transform: uppercase;
}
#head .cursor:after {
animation: blink 1s linear infinite alternate;
background: #b5cfd7;
content: "";
display: inline-block;
height: 75%;
margin-left: 30px;
opacity: 0;
width: 5px;
}
/* Animation */
#keyframes blink {
0% {
opacity: 0;
}
25% {
opacity: 1;
}
100% {
opacity: 0;
}
}
The JS:
var sentences = [];
var currentText;
$(document).ready(function(){
$('.text p').each(function(){
var text = $(this).text();
text += " ";
sentences.push(text);
});
currentText = sentences.shift();
typeWord(currentText);
});
jQuery.fn.extend({
appendChars: function(char){
$(this).text(char);
}
});
function spliter(string){
return string.trim().split("");
}
function appendTextLine(){
return $('<span class=""></span>').appendTo('.title');
}
function typeWord(text){
if (!text){
return;
}
var charArray = [];
for (i = 0; i < text.length; i++){
var char = text.slice(0,i);
charArray.push(char);
}
var textLine = appendTextLine();
$('.cursor').removeClass('cursor');
textLine.addClass('cursor');
var interval = setInterval(function(){
firstChar = charArray.shift();
$(textLine).appendChars(firstChar);
if (charArray.length === 0){
currentText = sentences.shift();
typeWord(currentText);
clearInterval(interval);
}
},100);
}
I have a pen here: https://codepen.io/joshrodgers/pen/yLjjzYb
Single line text version here: https://codepen.io/joshrodgers/pen/RwyJroQ
There were two problems with my initial code, it wouldn't work with dynamic text, which this solves because it's not based on a width and two the text was not centered in the window, which I didn't realize when I create this post, but the solution also solves that issue as well.
Hope this helps someone!
Thanks,
Josh
Related
I created a progress bar in CSS, with 4 goals: (0, 1.000, 10.000 and 100.000).
The goal amounts are displayed outside the progress bar, but inside the progress bar I would like to create 2 intervals exactly below the second and the third goal (first goal and last goal are the beginning and the end of the bar).
The interval should be like a line from the top to the bottom of the bar, visible also if the progress bar passes over them (for this I set a transparence on the progress bar's color).
Which is the best way to do it?
.progress-goals {
max-width: 66%;
margin: 0 auto 0;
display: flex;
justify-content: space-between;
}
.progress-goals h3 {
display: inline-block;
}
.progress-goals:last-child {
flex: 1;
}
.progress-bg {
margin: 0px auto 0px;
max-width: 66%;
height: 78px;
border-radius: 5px;
text-align: center;
-moz-box-shadow: inset 0 0 10px #ccc;
-webkit-box-shadow: inset 0 0 10px #ccc;
box-shadow: inset 0 0 10px #ccc;
}
.progress-bar {
height: 78px;
border-radius: 5px;
float: left;
width: 45%;
/* fallback */
background:
rgba(28, 53, 120, 0.7);
}
.progress-bg h4.goal,
.progress-bg h4.raised {
font-family: Arial, sans-serif;
font-size: 2em;
font-weight: 600;
line-height: 78px;
margin: 0;
padding: 0;
text-align: center;
display: inline;
}
.progress-bg h4.raised {
display: inline;
color: #fff;
text-align: center;
}
.progress-bg h4.goal {
color: #b2b2b2;
text-align: center;
}
#keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Firefox */
#-moz-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Safari and Chrome */
#-webkit-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Internet Explorer */
#-ms-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
body .progress-bg div {
-webkit-animation: progress-bar 2s ease forwards;
-moz-animation: progress-bar 2s ease forwards;
-o-animation: progress-bar 2s ease forwards;
animation: progress-bar 2s ease forwards;
}
#keyframes progress-bar {
from {
width: 0%;
}
to {
width: 45%;
}
}
<div class="progress-goals">
<h3 class="no-goal">$0</h3>
<h3 class="first-goal">$1,000</h3>
<h3 class="second-goal">$10,000</h3>
<h3 class="last-goal">$100,000</h3>
</div>
<div class="progress-bg" id="progress-bg">
<div class="first-goal-bar"></div>
<div class="second-goal-bar"></div>
<div class="progress-bar">
<h4 class="raised">$5,000 raised </h4>
</div>
</div>
An example of what I want (the main text eg. subscribe): https://sounddrout.com/
My code basically has a repeating typewriter effect on it and it just goes from right to left. Although I want it to do so but in a centered fashion (Check the website linked as an example). I want it to come out from the middle so its equal on both sides and expands out. Think like the center thing in google docs.
body {
margin: 0px;
}
.container {
display: grid;
grid-template-columns: 1fr;
}
/*Text*/
.font {
font-family: 'Source Sans Pro', monospace;
}
.mid {
text-align: center;
}
.txtsize {
font-size: 40px;
}
h1 {
width: max-content;
position: relative;
font-size: 40px;
display: grid;
}
.textbody {
margin: 120px;
font-family: "Source Sans Pro", sans-serif;
display: grid;
place-content: center;
text-align: center;
background: var(--bg-color);
font: 200;
}
/*typwriter*/
:root {
--bg-color: hsl;
--typewriterSpeed: 5s;
--blinkLength: 650ms;
--typewriterCharacters: 20;
}
/* Type Writer Effect */
h1::before,
h1::after {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
h1::before {
background: white;
animation: typewriter var(--typewriterSpeed) steps(20) infinite;
}
h1::after {
width: 0.1em;
background: black;
animation: typewriter var(--typewriterSpeed) steps(20) infinite;
}
#keyframes typewriter {
from {
left: 0%;
}
45% {
left: 100%;
}
65% {
left: 100%;
}
85% {
left: 0%;
}
to {
left: 0%;
}
}
#keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<body>
<div class="textbody">
<h1>
Subscribe To FuryRex09
</h1>
</div>
</body>
Any ideas?
Sorry if I wasn't very clear I had a lot of trouble explaining my issue.
P.S here's a Codepen - https://codepen.io/furyrex09/pen/bGaybOe (;
if you can use JavaScript . this we be lot easier to do .
$("#typed").typed({
strings: ["This is first.", "This is second.", "Add any text you like here."],
typeSpeed: 100,
startDelay: 0,
backSpeed: 60,
backDelay: 2000,
loop: true,
cursorChar: "|",
contentType: 'html'
});
#import url('https://fonts.googleapis.com/css?family=Work+Sans');
html, body {
height: 100vh;
font-family: 'Work Sans', sans-serif;
font-weight: bold;
color: #fff;
letter-spacing: 5px;
}
body {
display: flex;
justify-content: center;
align-items: center;
background-size: cover;
background: linear-gradient(to right, #0cebeb, #20e3b2, #29ffc6);
margin: 0;
}
.type-wrap {
font-size: 50px;
padding: 20px;
}
/* the above is for styling puposes only */
.typed-cursor{
opacity: 1;
-webkit-animation: blink 0.7s infinite;
-moz-animation: blink 0.7s infinite;
animation: blink 0.7s infinite;
}
#keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/1.1.1/typed.min.js"></script>
<div class="type-wrap">
<span id="typed" style="white-space:pre;" class="typed">
</span>
</div>
Here's my solution to this:
// TYPEWRITER //
const typedTextSpan = document.querySelector(".typed-text");
const cursorSpan = document.querySelector(".cursor");
const textArray = ["YouTuber", "Writer", "Designer", "Creator", "Programmer", "Gamer"]
const typingDelay = 200;
const erasingDelay = 100;
const newTextDelay = 2000;
let textArrayIndex = 0;
let charIndex = 0;
function type() {
if(charIndex < textArray[textArrayIndex].length) {
if(!cursorSpan.classList.contains("typing")) cursorSpan.classList.add("typing");
typedTextSpan.textContent += textArray[textArrayIndex].charAt(charIndex);
charIndex++;
setTimeout(type, typingDelay);
}
else {
cursorSpan.classList.remove("typing");
setTimeout(erase, newTextDelay);
}
}
function erase() {
if(charIndex > 0) {
if(!cursorSpan.classList.contains("typing")) cursorSpan.classList.add("typing");
typedTextSpan.textContent = textArray[textArrayIndex].substring(0,charIndex-1);
charIndex--;
setTimeout(erase, erasingDelay)
}
else {
cursorSpan.classList.remove("typing");
textArrayIndex++;
if(textArrayIndex>=textArray.length) textArrayIndex=0;
setTimeout(type, typingDelay + 800);
}
}
document.addEventListener("DOMContentLoaded", function() {
if(textArray.length) setTimeout(type, newTextDelay + 250);
});
/* Text */
h1 {
position: relative;
font-size: 40px;
}
.textbody {
margin-top: 100px;
font-family: "Source Sans Pro", sans-serif;
font-weight: bold;
background: var(--bg-color);
font: 200;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}
.typed-text {
font-weight: normal;
color: #dd7732;
}
/* Root */
:root {
--bg-color: hsl;
--typewriterSpeed: 5s;
--blinkLength: 825ms;
--typewriterCharacters: 20;
}
/* Type Writer Effect */
.cursor {
display: inline-block;
width: 3px;
background-color: #ccc;
margin-left: 0.1rem;
animation: blink 1s infinite;
}
.cursor.typing {
animation: none;
}
#keyframes blink {
0% {background-color: #ccc;}
49% {background-color: #ccc; }
50% {background-color: transparent; }
99% {background-color: transparent; }
100% {background-color: #ccc; }
}
<body>
<div class="textbody">
<h1>
I am a <span class="typed-text"></span><span class="cursor typing"> </span>
</h1>
</div>
<script src="main.js"></script>
</body>
I am doing a typewriter effect where my name gets typed out, and the only thing that works to keep it centered is justify-content: center. The only thing is, I cannot put a paragraph underneath the flex item, and paragraph acts like it isn't there and nothing seems to work. I have tried top: 315px; but it doesn't work.
body {
min-height: 100%;
display: flex;
justify-content: center;
}
h1 {
position: absolute;
animation: type 1s steps(22), blinkTextCursor 500ms steps(44) infinite normal;
overflow: hidden;
white-space: nowrap;
border-right: 4px solid black;
width: 14ch;
transform: translateY(-50%) scale(2);
}
#keyframes type {
0% {
width: 0ch;
}
100% {
width: 15ch;
}
}
#keyframes blinkTextCursor {
from {
border-right-color: black;
}
to {
border-right-color: transparent;
}
#welcome {
position: relative;
top: 315px;
}
<body>
<h1>Hi, I'm Winston</h1>
<p id="welcome">text</p>
</body>
Just needed to remove position absolute and add a flex-direction which in your case is column
body {
min-height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
h1 {
animation: type 1s steps(22),
blinkTextCursor 500ms steps(44) infinite normal;
overflow: hidden;
white-space: nowrap;
border-right: 4px solid black;
width: 14ch;
transform:translateY(-50%) scale(2);
}
#keyframes type {
0% {
width: 0ch;
}
100% {
width: 15ch;
}
}
#keyframes blinkTextCursor{
from{
border-right-color:black;
}
to{
border-right-color:transparent;
}
#welcome {
position: relative;
top: 315px;
}
<body>
<h1>Hi, I'm Winston</h1>
<p id="welcome">text</p>
</body>
Add this to your css.
#welcome{
position: absolute;
margin-top: 100px;
}
Final CSS.
body {
min-height: 100%;
display: flex;
justify-content: center;
align-content: center;
}
h1 {
position: absolute;
animation: type 1s steps(22), blinkTextCursor 500ms steps(44) infinite normal;
overflow: hidden;
white-space: nowrap;
border-right: 4px solid black;
width: 14ch;
transform: translateY(-50%) scale(2);
}
#welcome{
position: absolute;
margin-top: 100px;
}
#keyframes type {
0% {
width: 0ch;
}
100% {
width: 15ch;
}
}
#keyframes blinkTextCursor {
from {
border-right-color: black;
}
to {
border-right-color: transparent;
}
}
I have a very basic piece of HTML with the objective of animating from display: none; to display: block with opacity changing from 0 to 1.
I'm using Chrome browser, which uses the -webkit prefixes as preference and did a -webkit-keyframes transition set to make the animation possible. However, it does not work and just changes the display without fading.
I have a JSFiddle here.
<html>
<head>
<style type="text/css">
#myDiv
{
display: none;
opacity: 0;
padding: 5px;
color: #600;
background-color: #CEC;
-webkit-transition: 350ms display-none-transition;
}
#parent:hover>#myDiv
{
opacity: 1;
display: block;
}
#parent
{
background-color: #000;
color: #FFF;
width: 500px;
height: 500px;
padding: 5px;
}
#-webkit-keyframes display-none-transition
{
0% {
display: none;
opacity: 0;
}
1%
{
display: block;
opacity: 0;
}
100%
{
display: block;
opacity: 1;
}
}
</style>
<body>
<div id="parent">
Hover on me...
<div id="myDiv">
Hello!
</div>
</div>
</body>
</head>
</html>
The display doesn't work with CSS transition or animation.
Use opacity, visibility or z-index. You can combine all them.
Try to use visibility: visible in place display: block and visibility: hidden in place display: none.
And finally, combine z-index: -1 and z-index: 100 for example.
Good work ;)
If you are using #keyframes you should use -webkit-animation instead of -webkit-transition. Here is the doc for #keyframes animation: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_CSS_animations.
See code snippet below:
.parent {
background-color: #000;
color: #fff;
width: 500px;
height: 500px;
padding: 5px;
}
.myDiv {
display: none;
opacity: 0;
padding: 5px;
color: #600;
background-color: #cec;
}
.parent:hover .myDiv {
display: block;
opacity: 1;
/* "both" tells the browser to use the above opacity
at the end of the animation (best practice) */
-webkit-animation: display-none-transition 1s both;
animation: display-none-transition 1s both;
}
#-webkit-keyframes display-none-transition {
0% {
opacity: 0;
}
}
#keyframes display-none-transition {
0% {
opacity: 0;
}
}
<div class="parent">
Hover on me...
<div class="myDiv">Hello!</div>
</div>
2016 UPDATED ANSWER
To reflect today's best practices, I would use a transition instead of an animation. Here is the updated code:
.parent {
background-color: #000;
color: #fff;
width: 500px;
height: 500px;
padding: 5px;
}
.myDiv {
opacity: 0;
padding: 5px;
color: #600;
background-color: #cec;
-webkit-transition: opacity 1s;
transition: opacity 1s;
}
.parent:hover .myDiv {
opacity: 1;
}
<div class="parent">
Hover on me...
<div class="myDiv">Hello!</div>
</div>
You can not animate display property. You can try with visibility: hidden to visibility: visible
Just use position: fixed and drop the z-index: -5 at the end of the #keyframe animation (you can do any negative index....
CSS:
#keyframes fadeOut {
0% { opacity: 1
}
99% {
opacity: 0;
z-index: 1;
}
100%{
opacity: 0;
display:none;
position: fixed;
z-index: -5;
}
}
It's been tricky, it's been nasty, but here it is...
FadeOut (opacity) first
then truly hide (meaning: not covering up or catching any clicks, getting height: 0,...)
display: <whatever> is indeed no option.
But animating scaleY is. Or translate to far-far-away or the old classic: animating max-height (from a specific high px value) down to 0px…
For an earlier version of this snippet with some more general info on „back and forth animation on class toggle“ (and preventing that animation upon initial page load look here.
const div = document.querySelector('.target')
function toggleTarget() {
div.classList.add('active');
div.classList.toggle('play');
}
/* REF https://stackoverflow.com/a/49575979 */
/* REF https://stackoverflow.com/questions/26607330/css-display-none-and-opacity-animation-with-keyframes-not-working/64857102#64857102 */
body, html { /* eye candy */
background: #444; display: flex; min-height: 100vh; align-items: center; justify-content: center;
}
button { font-size: 4em; border-radius: 20px; margin-left: 60px;}
div { /* eye candy */
width: 200px; height: 100px; border-radius: 20px;
background: green; display: flex; align-items: center; justify-content: center;
font-family: sans-serif; font-size: 2em; color: white; text-align: center;
text-shadow: 0px 2px 4px rgba(0,0,0,.6);
}
/* using this extra .active class prevents that there is an animation already on loading */
.active {
animation: fadeAndHideBack 1s linear forwards;
}
.play {
opacity: 0;
/* learning curve: setting background "awaits" animation finish,
setting scale prematurely jumps to it, then doing animation from there */
animation: fadeAndHide 1s linear forwards;
}
#keyframes fadeAndHide {
0% { opacity: 1; }
99.9% { opacity: 0; max-height: 100px; }
100% { opacity: 0; max-height: 0; }
}
#keyframes fadeAndHideBack {
0% { opacity: 0; max-height: 0; }
0.1% { opacity: 0; max-height: 100px; }
100% { opacity: 1; }
}
<div class="target"></div>
<button onclick="toggleTarget()">
Toggle
</button>
You can use Javascript to change both the display properties and animation. You can't put display in #keyframes.
Start with the element display:none. Then simultaneously add display:block and animation:* classes.
Here's a working example with animation in/out.
add this css ;
.fade:not(.show) {
opacity: 1;
}
this work for me..
How about this example: jsfiddle
The issue was needing to use an animation rather than transition with keyframes
#-webkit-keyframes fadeAnimation {
0% {
opacity: 0;
}
25% {
opacity: 0.25;
}
50% {
opacity: 0.5;
}
100% {
opacity: 1;
}
}
#myDiv {
opacity: 0;
padding: 5px;
color: #600;
background-color: #CEC;
}
#parent {
background-color: #000;
color: #FFF;
width: 500px;
height: 500px;
padding: 5px;
}
#parent:hover #myDiv {
-webkit-animation: fadeAnimation 6s;
}
You can't animate the display property. You can animate the visibility property. But visibility is not the same as display, as it will not remove the div element completely from the DOM (the property, visibility:collapse, can remove an element from the DOM, if the element is a table. This is an exception). You can instead animate CSS properties height and width. For instance, the below code will animate the square-block out.
function myAnimation(){
var square= document.getElementById('square');
if(square.getAttribute("class")==='square'){
square.classList.add('animation');
}else{
square.classList.remove('animation');
}
}
.square {
background-color:blue;
transform: translate(0, 0);
width: 100px;
height: 100px;
opacity: 1;
transition: all 0.5s ease-out;
}
.square.animation {
transform: translate(-260px, -260px);
width: 0;
height: 0;
opacity: 0;
transition: all 0.5s ease-in;
}
<html>
<body>
<div class="square" id="square"></div>
<br/>
<button onclick="myAnimation()">Animate</button>
</body>
</html>
FYI, I have used CSS transitions to animate the div. Hope this was useful.
I need to have span with text aligned in the center.
Previously I have used line-height for this purpose, but in this case the text for some items are longer and this doesn't work any more.
JSFiddle: http://jsfiddle.net/4jSdu/
HTML:
<ul>
<li><a><span>Short</span></a>
</li>
<li><a><span>Why Should I Monitor?</span></a>
</li>
</ul>
CSS:
ul {
position: relative;
overflow: hidden;
}
span {
background-color: rgba(216, 25, 11, 0.75);
display: block;
height: 70px;
line-height: 70px;
width: 135px;
color: black;
text-align: center;
/*margin: auto 0;*/
font-weight: bold;
font-size: 15px;
position: absolute;
bottom: 14px;
}
li, a {
width: 135px;
height: 100px;
display: inline-block;
}
EDIT:
I want to note that span element has value bottom: 14px. THere is also animate effect on this span. when page loads span has value bottom: -70px (container has overlfow: hidden,s o this span is not seen) and then it appears (using .animate) and goes to bottom: 14px. So the sollution should consider this.
I cannot get this animate effect working in jsfiddle (http://jsfiddle.net/pr5cL/), but it works on my page that is locally created.
$("ul li:not(.img_active)").mouseenter(function() {
$(this).find("span").css("bottom","-55px");
$(this).find("span").animate({bottom:15},500);
}).mouseleave(function(){
$(this).find("span").animate({bottom:-70},500);
});
Here is link: http://www.sheerdigitaltest.net/janus/
Something like this maybe?
span {
display: inline-block;
line-height:1.25;
vertical-align:middle;
width: 135px;
color: black;
text-align: center;
font-weight: bold;
font-size: 15px;
}
a {
background-color: rgba(216, 25, 11, 0.75);
height: 70px;
line-height: 70px;
font-size:0;
overflow:hidden;
}
li, a {
width: 135px;
display: inline-block;
vertical-align:top;
}
span {
-webkit-animation: slidein 2s ; /* Safari 4+ */
-moz-animation: slidein 2s ; /* Fx 5+ */
-o-animation: slidein 2s ; /* Opera 12+ */
animation: slidein 2s ; /* IE 10+ */
}
#-webkit-keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
#-moz-keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
#-o-keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
#keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
Jsfiddle
No IE7 or earlier support. Animation support as per comments.