Reputation: 57
I am trying to make the text randomly positioned on the screen. How do I do that?
I am using Textillate
<h1 class="tlt1">Go </h1>
Upvotes: 0
Views: 3811
Reputation: 318
You can achieve this either by position:fixed
OR position:absolute
.
$('.tlt').each(function(){
$(this).css({"left": Math.random() * window.outerWidth , "top": Math.random() * window.outerHeight}).textillate();
});
OR
$('h1').each(function(){
$(this).css({"left": Math.random() * window.outerWidth , "top": Math.random() * window.outerHeight}).textillate();
});
Updated jsfiddle
Upvotes: 1
Reputation: 673
You should set your CSS for your h1 tags to position:fixed
. Then in your javascript for each h1 your generate set its left
property to Math.random() * window.outerWidth
and its top
property to Math.random() * window.outerHeight
.
Upvotes: 0