我想每次页面重新加载时随机放置多个div。
如何将其限制为我的浏览器大小?
// draggable
$(function() {
$(".draggable").draggable({ containment: "#container"});
});
// random distribution
$('.draggable').each(function(i,el){
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var tLeft = Math.floor(Math.random()*winWidth),
tTop = Math.floor(Math.random()*winHeight);
$(el).css({position:'absolute', left: tLeft, top: tTop});
});