标签,方便连接导航跳转。
3、在新建的内,添加横向导航要显示的内容。
4、在
下方添加一个。
5、源文件html保存后,使用浏览器打开预览效果。
CSS3 移动端 滚动置顶 吸顶
如果是在回调里置顶DIV的话(比如点击事件),可以用scrollIntoView。
scrollIntoView如果不想吸顶 可以加个before伪类设置高度
CSS3滚动置顶目前有两种解决方案:
第一种(主流):transform: translate3d(x,y,z)
第二种(未来):position: sticky;top:xxx;
假设需求:
需求一:滚动过程中A ,C区域不吸顶,B区域吸顶
VUE框架推荐直接使用vantUI插件,indexbar索引栏。
vantUI原理用的是transform。
以上面图片为例大致讲解:
1.transform对JS的能力要求高些,页面加载完毕后,给每个B区域对应的DIV设置translate3d的Y轴值,值为B对应div离顶部的高度。
2.当开始滚动起来后,Y轴值为原来值减去滚动条滚动距离值
3.当Y轴值小于0的时候,锁死为0,就自动吸顶了
4.当待置顶DIV的translate3d Y轴值小于DIV的高度时,已置顶DIV的Y轴值开始变为负数,这样会有一个顶出的效果
5.已置顶DIV被待置顶DIV顶出一定距离(一般两倍DIV高度),取消translate3d属性,
6.回滚反向计算即可
需求二:滚动过程中 C不吸顶,B吸顶,A一直吸顶 B在A下面
这个需求vantUI(v2.9.3)目前解决不了,采用translate太复杂,决定采用CSS3新属性position: sticky。
如果是2018年使用该属性兼容性还是个问题,但来到2020年下半年,对大部分生产环境都不是问题。博主测试的IOS11和安卓小米 华为 都支持该属性。
博主的建议是:如果是公司APP内嵌H5页面或者微信打开可以使用该属性,如果纯H5页面 ,建议translate.
position: sticky;字面意思就是粘性定位。
可以粘顶部也可以粘底部 右侧 左侧。
所以除了position: sticky;还要给一个定位值,比如top:0px或者right:0px就可以了 非常简单。
比如直接给Bdiv设置下面样式就行
实际使用要注意下面几点:
1.如果想兼容IOS12 IOS11 必须带position: -webkit-sticky;而且要在样式表里写,不能写在style里。
2.容器相关。只有要移除容器范畴才起作用。比如body的height不要设置100%,height:100%表示所有元素一直在屏幕范围
css滚动效果 css里面怎么设置为滚动形式
css怎么实现文字无缝上下滚动
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159!DOCTYPEhtmlheadmetahttp-equiv="Content-Type"content="text/html;charset=gb2312"/title向上下左右不间断无缝滚动效果(兼容火狐和IE)/title/headbodydivid="colee" divid="colee1"p此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/pp此处放文字。。。。。。。。。/p/divdivid="colee2"/div/divscriptvarspeed=30;varcolee2=document.getElementById("colee2");varcolee1=document.getElementById("colee1");varcolee=document.getElementById("colee");colee2.innerHTML=colee1.innerHTML;//克隆colee1为colee2functionMarquee1(){//当滚动至colee1与colee2交界时if(colee2.offsetTop-colee.scrollTop=0){colee.scrollTop-=colee1.offsetHeight;//colee跳到最顶端}else{colee.scrollTop++}}varMyMar1=setInterval(Marquee1,speed)//设置定时器//鼠标移上时清除定时器达到滚动停止的目的colee.onmouseover=function(){clearInterval(MyMar1)}//鼠标移开时重设定时器colee.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}/script!--向上滚动代码结束--!--下面是向下滚动代码--divid="colee_bottom" divid="colee_bottom1"pimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/ppimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/divdivid="colee_bottom2"/div/divscriptvarspeed=30varcolee_bottom2=document.getElementById("colee_bottom2");varcolee_bottom1=document.getElementById("colee_bottom1");varcolee_bottom=document.getElementById("colee_bottom");colee_bottom2.innerHTML=colee_bottom1.innerHTMLcolee_bottom.scrollTop=colee_bottom.scrollHeightfunctionMarquee2(){if(colee_bottom1.offsetTop-colee_bottom.scrollTop=0)colee_bottom.scrollTop+=colee_bottom2.offsetHeightelse{colee_bottom.scrollTop--}}varMyMar2=setInterval(Marquee2,speed)colee_bottom.onmouseover=function(){clearInterval(MyMar2)}colee_bottom.onmouseout=function(){MyMar2=setInterval(Marquee2,speed)}/script!--向下滚动代码结束--!--下面是向左滚动代码--divid="colee_left" tablecellpadding="0"cellspacing="0"border="0"trtdid="colee_left1"valign="top"align="center"tablecellpadding="2"cellspacing="0"border="0"tralign="center"tdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/td/tr/table/tdtdid="colee_left2"valign="top"/td/tr/table/divscript//使用div时,请保证colee_left2与colee_left1是在同一行上.varspeed=30//速度数值越大速度越慢varcolee_left2=document.getElementById("colee_left2");varcolee_left1=document.getElementById("colee_left1");varcolee_left=document.getElementById("colee_left");colee_left2.innerHTML=colee_left1.innerHTMLfunctionMarquee3(){if(colee_left2.offsetWidth-colee_left.scrollLeft=0)//offsetWidth是对象的可见宽度colee_left.scrollLeft-=colee_left1.offsetWidth//scrollWidth是对象的实际内容的宽,不包边线宽度else{colee_left.scrollLeft++}}varMyMar3=setInterval(Marquee3,speed)colee_left.onmouseover=function(){clearInterval(MyMar3)}colee_left.onmouseout=function(){MyMar3=setInterval(Marquee3,speed)}/script!--向左滚动代码结束--!--下面是向右滚动代码--divid="colee_right" tablecellpadding="0"cellspacing="0"border="0"trtdid="colee_right1"valign="top"align="center"tablecellpadding="2"cellspacing="0"border="0"tralign="center"tdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/tdtdpimgsrc="/uploads/3d55fe886f8945bd93edee3146bf3251.png" data-original="/jscss/demoimg/200907/bg3.jpg"/p/td/tr/table/tdtdid="colee_right2"valign="top"/td/tr/table/divscriptvarspeed=30//速度数值越大速度越慢varcolee_right2=document.getElementById("colee_right2");varcolee_right1=document.getElementById("colee_right1");varcolee_right=document.getElementById("colee_right");colee_right2.innerHTML=colee_right1.innerHTMLfunctionMarquee4(){if(colee_right.scrollLeft=0)colee_right.scrollLeft+=colee_right2.offsetWidthelse{colee_right.scrollLeft--}}varMyMar4=setInterval(Marquee4,speed)colee_right.onmouseover=function(){clearInterval(MyMar4)}colee_right.onmouseout=function(){MyMar4=setInterval(Marquee4,speed)}/script!--向右滚动代码结束--/body/html常用JS图片、文字滚动(...大小:1.41K 已经过百度安全检测,放心下载点击下载
追问
这是JS的代码?我要的HTML的
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至836084111@qq.com 举报,一经查实,本站将立刻删除。