Created
June 7, 2014 08:16
-
-
Save ddbruce/75e13171facfb7b8df5c to your computer and use it in GitHub Desktop.
Code for CSS3 marquee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Test</title> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<script src="marq.js"></script> | |
<script src="jquery.min.js"></script> | |
</head> | |
<body> | |
<div id="marquee"> | |
<div id="left"></div><div id="right"></div> | |
</div> | |
</body> | |
<script type="text/javascript"> | |
$(document).load( move(text1,imageloc1) ); | |
</script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
overflow: hidden; | |
} | |
#marquee { | |
font-family: "Myriad Pro", sans-serif; | |
font-size: 50px; | |
position: relative; | |
display: inline-block; | |
-webkit-animation: marquee /*30s*/ linear infinite; | |
-moz-animation: marquee /*30s*/ linear infinite; | |
-ms-animation: marquee /*30s*/ linear infinite; | |
animation: marquee /*30s*/ linear infinite; | |
} | |
#left, #right { | |
display: inline; | |
white-space: nowrap; | |
} | |
span.piece::after { | |
display: inline-block; | |
margin: 10px; | |
width: 100px; | |
height: 100px; | |
content: ""; | |
background: transparent url('conc.png') no-repeat; | |
vertical-align: middle; | |
margin: 0 80px; | |
} | |
@-webkit-keyframes marquee { | |
0% { -webkit-transform: translateX(0%); } | |
100% { -webkit-transform: translateX(-50%); } | |
} | |
@-moz-keyframes marquee { | |
0% { -moz-transform: translateX(0%); } | |
100% { -moz-transform: translateX(-50%); } | |
} | |
@-ms-keyframes marquee { | |
0% { -ms-transform: translateX(0%); } | |
100% { -ms-transform: translateX(-50%); } | |
} | |
@keyframes marquee { | |
0% { transform: translateX(0%); } | |
100% { transform: translateX(-50%); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text1 = ["Headline 1 goes here", "Headline two is placed in this location", "This is a short headline with <i>italics</i>", "This is a very, very, very, very, very long headline with <b>bold</b> and <i>italics</i> and <b><i>bold italics</i></b>"] | |
var text2 = ['headline 1','headline 2','headline4 haha.'] | |
var imageloc1 = "conc.svg" | |
function move(text,imageloc) { | |
var chars = 0; | |
for (var i = 0; i < text.length; i++) { | |
$('#left').append("<span class='piece'>" + text[i] + "</span>"); | |
$('#right').append("<span class='piece'>" + text[i] + "</span>"); | |
chars+=text[i].length; | |
} | |
var dur = Math.floor(chars/10) + text.length; | |
document.getElementById('marquee').style.webkitAnimationDuration = dur + "s"; | |
document.getElementById('marquee').style.mozAnimationDuration = dur + "s"; | |
document.getElementById('marquee').style.msAnimationDuration = dur + "s"; | |
document.getElementById('marquee').style.animationDuration = dur + "s"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment