pos机出现代码h4,手机网站顶部滑动菜单栏

 新闻资讯2  |   2023-05-26 09:52  |  投稿人:pos机之家

网上有很多关于pos机出现代码h4,手机网站顶部滑动菜单栏的知识,也有很多人为大家解答关于pos机出现代码h4的问题,今天pos机之家(www.poszjia.com)为大家整理了关于这方面的知识,让我们一起来看下吧!

本文目录一览:

1、pos机出现代码h4

pos机出现代码h4

现在是移动互联网时代,我们也得跟上时代的潮流,传统的pc网站慢慢转型,开始转成wap网站,并且pc的排版布局结构也不在适用于手机上

例如最直观的一个感受就是菜单,我们平时在使用网页的时候,很明显的感觉到这个网页菜单变得不一样,那么这一期给大家带来的干货是顶部菜单滑动效果

直接上代码演示

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8" />

<title>顶部菜单滑动效果分享</title>

<meta name="viewport" content="width="360px",height="auto" />

<style>

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,form,input,p,th,td,table,textarea,select{margin:0;padding:0;}

h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}

th,em{font-style:normal;font-weight:normal;}

ol,ul{list-style:none;}

table{border-collapse:collapse;border-spacing:0;}

img,a img{border:0;}

body{font:12px \'Microsoft YaHei\',Arial;color:#666;background-color:#eee;}

.nav{width="360px",height="auto" />

.nav ul{position:absolute;left:0;top:0;width="360px",height="auto" />

.nav ul li{width="360px",height="auto" />

.nav a{color:#fff;width="360px",height="auto" />

</style>

</head>

<body>

<div class="nav" id="nav">

<ul>

<!-- 定义好菜单名称 这里演示定义了10个菜单-->

<li><a href="#">menu1</a></li>

<li><a href="#">menu2</a></li>

<li><a href="#">menu3</a></li>

<li><a href="#">menu4</a></li>

<li><a href="#">menu5</a></li>

<li><a href="#">menu6</a></li>

<li><a href="#">menu7</a></li>

<li><a href="#">menu8</a></li>

<li><a href="#">menu9</a></li>

<li><a href="#">menu10</a></li>

</ul>

</div>

<script>

// 这里需要初始化

window.Swipe = function(b, a) {

if (!b) {

return null

}

this.options = a || {};

this.index = this.options.startSlide || 0;//开始的导航页的第几屏

this.speed = this.options.speed || 300;//速度

this.lwidth="360px",height="auto" />

this.delay = this.options.auto || 0;//自动滚动menu速度0为不自动滚动

this.container = b;//在那个容器内

this.element = this.container.children[0];//

this.setup();

if (this.delay != 0) {

this.begin();

}

if (this.element.addEventListener) {

this.element.addEventListener("touchstart", this, false);

this.element.addEventListener("touchmove", this, false);

this.element.addEventListener("touchend", this, false);

this.element.addEventListener("touchcancel", this, false);

this.element.addEventListener("webkitTransitionEnd", this, false);

this.element.addEventListener("msTransitionEnd", this, false);

this.element.addEventListener("oTransitionEnd", this, false);

this.element.addEventListener("transitionend", this, false);//监听过度动画是否结束

window.addEventListener("resize", this, false)

}

};

Swipe.prototype = {

//设置其基本样式

setup: function() {

this.slides = this.element.children;

this.width="360px",height="auto" />

if (!this.width="360px",height="auto" />

return null

}

this.element.style.width="360px",height="auto" />

var a = this.slides.length;

while (a--) {

var b = this.slides[a];

b.style.width="360px",height="auto" />

}

this.slide(this.index, 0);

},

slide: function(a, c) {

var b = this.element.style;

if (c == undefined) {

c = this.speed

}

//过度效果需要花费时间

b.webkitTransitionDuration = b.MozTransitionDuration = b.msTransitionDuration = b.OTransitionDuration = b.transitionDuration = c + "ms";

this.index = a

if(a * this.width="360px",height="auto" />

// b.MozTransform = b.webkitTransform = "translate3d(" + -((Math.ceil((this.slides.length*this.lwidth="360px",height="auto" />

// b.msTransform = b.OTransform = "translateX(" + -((Math.ceil((this.slides.length*this.lwidth="360px",height="auto" />

return false;

}

else{

b.MozTransform = b.webkitTransform = "translate3d(" + -(a * this.width="360px",height="auto" />

b.msTransform = b.OTransform = "translateX(" + -(a * this.width="360px",height="auto" />

}

},

getPos: function() {

return this.index

},

//前一个,

prev: function(a) {

this.delay = a || 0;

clearTimeout(this.interval);

// console.log(this.index);

if (this.index) {

this.slide(this.index - 1, this.speed)

//console.log( this.index);

} else {

this.slide(this.length - 1, this.speed)

}

},

//后一个

next: function(a) {

this.delay = a || 0;

clearTimeout(this.interval);

if (this.index < this.length - 1) {

this.slide(this.index + 1, this.speed)

} else {

this.slide(0, this.speed)

}

},

// 开始位置

begin: function() {

var a = this;

console.log(a);

this.interval = (this.delay) ? setTimeout(function() {

a.next(a.delay)

},

this.delay) : 0

},

// 停止

stop: function() {

this.delay = 0;

clearTimeout(this.interval)

},

resume: function() {

this.delay = this.options.auto || 0;

this.begin()

},

handleEvent: function(a) {

switch (a.type) {

case "touchstart":

this.onTouchStart(a);

break;

case "touchmove":

this.onTouchMove(a);

break;

case "touchcancel":

case "touchend":

this.onTouchEnd(a);

break;

case "webkitTransitionEnd":

case "msTransitionEnd":

case "oTransitionEnd":

this.transitionEnd(a);

break;

case "resize":

this.setup();

break

}

},

transitionEnd: function(a) {

if (this.delay) {

this.begin()

}

},

onTouchStart: function(a) {

this.start = {

pageX: a.touches[0].pageX,

pageY: a.touches[0].pageY,

time: Number(new Date())

};

// console.log(this.start)

this.isScrolling = undefined;

this.deltaX = 0;

this.element.style.MozTransitionDuration = this.element.style.webkitTransitionDuration = 0;

a.stopPropagation()

},

onTouchMove: function(a) {

if (a.touches.length > 1 || a.scale && a.scale !== 1) {

return

}

this.deltaX = a.touches[0].pageX - this.start.pageX;

if (typeof this.isScrolling == "undefined") {

//判断是横向还是树向滑动

this.isScrolling = !!(this.isScrolling || Math.abs(this.deltaX) < Math.abs(a.touches[0].pageY - this.start.pageY))

}

if (!this.isScrolling) {

a.preventDefault();

clearTimeout(this.interval);

this.deltaX = this.deltaX / ((!this.index && this.deltaX > 0 || this.index == this.length - 1 && this.deltaX < 0) ? (Math.abs(this.deltaX) / this.width="360px",height="auto" />

this.element.style.MozTransform = this.element.style.webkitTransform = "translate3d(" + (this.deltaX - this.index * this.width="360px",height="auto" />

a.stopPropagation()

}

},

onTouchEnd: function(c) {

var b = Number(new Date()) - this.start.time < 250 && Math.abs(this.deltaX) > 20 || Math.abs(this.deltaX) > this.width="360px",height="auto" />

a = !this.index && this.deltaX > 0 || this.index == this.length - 1 && this.deltaX < 0;

if (!this.isScrolling) {

this.slide(this.index + (b && !a ? (this.deltaX < 0 ? 1: -1) : 0), this.speed)

}

c.stopPropagation()

}

};

//开始调用插件

//document.getElementById(\'nav\')是直接获取nav菜单

var slider=new Swipe(document.getElementById(\'nav\'),{speed:300,auto:0,width="360px",height="auto" />

</script>

</body>

</html>

大家有什么不懂的欢迎下面留言

以上就是关于pos机出现代码h4,手机网站顶部滑动菜单栏的知识,后面我们会继续为大家整理关于pos机出现代码h4的知识,希望能够帮助到大家!

转发请带上网址:http://www.poszjia.com/newsone/58078.html

你可能会喜欢:

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 babsan@163.com 举报,一经查实,本站将立刻删除。