I have been experimenting with trying to make an image appear as if it is floating by using jQuery to animate it vertically. After some research, I stumbled upon this thread: Animating a div up and down repeatedly which seems to have the solution I need. However, even after implementing the code on my website, I can't seem to get the image to behave like the example shown here. Here is the current state of the code that I am working with.
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type ="text/javascript" src="script.js"></script>
<!-- Checking to see if running properly
<script>
window.onload = function() {
if (window.jQuery) {
// jQuery is loaded
alert("Yeah!");
} else {
// jQuery is not loaded
alert("Doesn't Work");
}
}
</script> -->
</head>
<body>
<table id="wrapper">
<tr>
<td><img src="PixelBuddah.png" class="bouncer" alt="PixelBuddah" /></td>
</tr>
</table>
<footer>
<p>...</p>
</footer>
</body>
</html>
CSS
html, body, #wrapper {
height:100%;
width: 100%;
margin: 0;
padding: 0;
border: 0;
}
#wrapper td {
vertical-align: middle;
text-align: center;
}
body {
background-color: #F5E9D3;
}
footer {
display: inline-block;
float: right;
text-align: right;
margin: auto;
margin-right: 1.2em;
font-family: 'Noto Sans', sans-serif;
font-weight: 600;
}
Javascript
function loop() {
$('.bouncer').animate({'top': '500'}, {
duration: 1000,
complete: function() {
$('.bouncer').animate({top: 0}, {
duration: 1000,
complete: loop});
}});
$('<div/>').text('exiting loop').appendTo($('.results'));
}
loop();
I'm still relatively new to this concept, so any guidance or assistance would be greatly appreciated! Thank you!