<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>About Me Scroll Effect w/ jQuery</title>
<style>
.wrapper {
padding: 100px;
width: 500px;
display: block;
text-align: center;
margin: 0 auto;
}
.roles {
font-size: 30px;
height: 50px;
vertical-align: middle;
overflow: hidden;
}
.roles div {
height: 50px;
-webkit-transition: margin-top 1s ease-in-out;
transition: margin-top 1s ease-in-out;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="roles">
<div>
I am a web developer.
</div>
<div>
I am a game creator.
</div>
<div>
I am a student.
</div>
<div>
I am an aspiring individual.
</div>
</div>
</div>
<script src="js/jquery-1.8.0.min.js"></script>
<script>
$(function() {
var current = 1;
var height = $('.roles').height();
var numberDivs = $('.roles').children().length;
var first = $('.roles div:nth-child(1)');
setInterval(function() {
var number = current * -height;
first.css('margin-top', number + 'px');
if (current === numberDivs) {
first.css('margin-top', '0px');
current = 1;
} else current++;
}, 2000);
})
</script>
</body>
</html>