【发布时间】:2017-01-13 14:26:14
【问题描述】:
我有一个半径为 10 像素并扩大到 100% 的圆圈。圆圈出现在整个视口的随机位置。动画在移动设备上看起来不错,但在更大的视口上像素化。
这是动画:https://rimildeyjsr.github.io/spotify-circle-animation/
任何想法如何在所有视口中保持圆圈一致?
jQuery
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
function makeDiv(colorChoice){
var divsize = 10;
var color = colorChoice;
console.log(color);
$newdiv = $('<div/>').css({
'width':divsize+'px',
'height':divsize+'px',
'background-color': color
});
var posx = (Math.random() * ($(document).width())).toFixed();
var posy = (Math.random() * ($(document).height())).toFixed();
$newdiv.css({
'position':'absolute',
'left':posx+'px',
'top':posy+'px',
'border-radius':'50%',
'display':'none'
}).appendTo( 'body' ).addClass('animate').css({'display':'block'}).one(animationEnd,function(){
$(this).remove();
});
};
var id = setInterval(function(){makeDiv('black')},5000);
CSS
html,body {
padding : 0;
margin: 0;
height: 100%;
width: 100%;
overflow-y: hidden;
overflow-x: hidden;
}
div {
height: 10px;
width:10px;
background-color: black;
border-radius: 50%;
top: 250px;
right: 10px;
left: 800px;
}
.animate {
-webkit-animation: expand 60s;
}
@-webkit-keyframes expand {
0%{
-webkit-transform: scale(0,0);
}
100%{
-webkit-transform: scale(100.0,100.0);
display: none;
}
}
【问题讨论】:
-
也许其中一种解决方案会有所帮助? stackoverflow.com/questions/19882283/…