css position fixed 在移动端上为什么会 晃来晃去

html-css013

css position fixed 在移动端上为什么会 晃来晃去,第1张

在自己手机上打开页面,向下滑动时这个div会出现短暂的向下瞬间移动之后马上跳回到最顶部,网上资料表明是position:fixed不兼容某些浏览器的缘故,解决方法有多种:

1.给这个设置了position:fixed的元素再设置一个CSS属性:-webkit-transform: translateZ(0)

2.给html, body元素设置CSS属性 {height:100%overflow:automargin: 0}

3.引入jquery1.7.2的类库,<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>

4.在fiexd内设置position:absolute,如:

<div style="position:fiexdbottom:0px">

<div style="position:absolute">

</div>

</div>

望采纳!

<!DOCTYPE html>

<html>

<head> 

<meta charset="utf-8"> 

<title></title> 

<style>

*{ padding:0margin:0font-size:14px }

body{

background: grey

}

.d{

position:fixedmargin:autoleft:0right:0bottom:24pxwidth: 160pxheight:120px

animation: d1 3s linear animation-fill-mode: both

}

@keyframes d1{

from{

bottom: 24px

}

to{

bottom: 360px

}

}

.d img{

height:120pxposition: absolutemargin:autoleft:0top:0animation: d2 2s 3s linear infinite animation-fill-mode: both

}

@keyframes d2{

0%,100%{

transform:rotate(0deg)

}

50%{  

left: 40px

transform:rotate(90deg)

}

}

</style>

</head>

<body>

<div class="d">

<img src="http://aimusic.image.alimmdn.com/Image/6d235b11f15838d6711ec6b0ca5e1a32.png"/>

</div>

</body>

</html>

1、如果是在pc端,想切换到第三页,可以直接点击底部的第三个小圆圈,想点击按钮跳到“第三页”,直接模拟点击第三个小圆圈就可以,可以写:$('.swiperpaginationspan').eq(2).trigger('click')

2、也可以写:swiper.slideTo(3, 1000, false),即可。

slideTo方法有三个参数:第一个参数是指定切换到某一页的索引;第二个参数是切换速度;第三个参数是布尔值,表示是否要触发onSlideChange回调函数。

扩展资料:

Swiper插件有可供选择的动画效果插件Swiper Animate,在这个插件里面有很多可供选择的动画比如缩放、旋转、摇晃等各种动画效果。

1、在使用Swiper Animate之前,必须要保证已经加载swiper.animate.min.js和animate.min.css。

2、在需要运动的元素上面增加类名  ani   ,和其他的类似插件相同,Swiper Animate需要指定几个参数:

swiper-animate-effect:切换效果,例如 fadeInUp

swiper-animate-duration:可选,动画持续时间(单位秒),例如 0.5s

swiper-animate-delay:可选,动画延迟时间(单位秒),例如 0.3s

参考资料来源:Swiper中文网