有沒有人跟我一樣,火狐瀏覽器運行正確,谷歌瀏覽器并不能完全達到-200,還留有一小段?
<script type="text/javascript">
?? ??? ??? ?window.onload = function () {
?? ??? ??? ??? ?var odiv = document.getElementById('div1');
?? ??? ??? ??? ?odiv.onmouseover = function () {
?? ??? ??? ??? ??? ?startMove(0);
?? ??? ??? ??? ?}
?? ??? ??? ??? ?odiv.onmouseout = function () {
?? ??? ??? ??? ??? ?startMove(-200);
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ??? ?var timer = null;
?? ??? ??? ?
?? ??? ??? ?function startMove (iTarget) {
?? ??? ??? ??? ?
?? ??? ??? ??? ?
?? ??? ??? ??? ?clearInterval(timer);
?? ??? ??? ??? ?var odiv = document.getElementById('div1');
?? ??? ??? ??? ?timer = setInterval(function () {
?? ??? ??? ??? ??? ?var speed = (iTarget - odiv.offsetLeft)/20;
?? ??? ??? ??? ??? ?speed = speed>0?Math.ceil(speed):Math.floor(speed);
?? ??? ??? ??? ??? ?if(odiv.offsetLeft == iTarget){
?? ??? ??? ??? ??? ?clearInterval(timer);
?? ??? ??? ??? ???? }else{
?? ??? ??? ??? ??? ??? odiv.style.left = odiv.offsetLeft + speed + 'px';
?? ??? ??? ??? ??? ??? }
?? ??? ??? ??? ?},30);?? ??? ??? ?
?? ??? ??? ?}
?? ??? ?</script>
2019-03-28
這是谷歌瀏覽器自帶的默認樣式,可以百度如何清除,我記得是有一大段css代碼的,直接拷貝到自己的css文件夾調用即可。
2018-12-07
設置 *{padding:0;margin:0}
2018-09-12
并沒有啊,是不是你在第一次沒添加取整判斷前在谷歌瀏覽器運行沒清緩存導致的呢