html锁机源码,webkit实现仿Iphone解锁插件

今天给大家分享一个CSS3实现仿Iphone解锁插件,

里面讲解使用webkit浏览器CSS渐变的效果实现。

304e82cd77c2f30912b87a1a1f2a59f0.png HTML

slider slide to unlock

CSS

#well {

width: 720px;

}

h2 {

width: 200%;

-webkit-animation: slidetounlock 5s infinite;

}

@-webkit-keyframes slidetounlock {

0% {

background-position: -720px 0;

}

100%{

background-position: 720px 0;

}

}

#well {

padding: 14px 20px 20px 20px;

-webkit-border-radius: 30px;

background: -webkit-gradient(linear,left top,left bottom,color-stop(0, #010101),color-stop(1, #181818));

border: 2px solid #454545;

overflow: hidden;

}

h2 {

font-size: 80px;

background: -webkit-gradient(linear,left top,right top,color-stop(0, #4d4d4d),color-stop(0.4, #4d4d4d),color-stop(0.5, white),color-stop(0.6, #4d4d4d),color-stop(1, #4d4d4d));

-webkit-background-clip: text;

-webkit-text-fill-color: transparent;

-webkit-animation: slidetounlock 5s infinite;

font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;

font-weight: 300;

padding: 0;

width: 200%;

}

@-webkit-keyframes slidetounlock {

0% {

background-position: -720px 0;

}

100% {

background-position: 720px 0;

}

} Js

$(function() {

$("#slider").draggable({

axis: 'x',

containment: 'parent',

drag: function(event, ui) {

if (ui.position.left > 550) {

$("#well").fadeOut();

} else {

// Apparently Safari isn't allowing partial opacity on text with background clip? Not sure.

// $("h2 span").css("opacity", 100 - (ui.position.left / 5))

}

},

stop: function(event, ui) {

if (ui.position.left < 551) {

$(this).animate({

left: 0

})

}

}

});

// The following credit: http://www.evanblack.com/blog/touch-slide-to-unlock/

$('#slider')[0].addEventListener('touchmove', function(event) {

event.preventDefault();

var el = event.target;

var touch = event.touches[0];

curX = touch.pageX - this.offsetLeft - 73;

if(curX <= 0) return;

if(curX > 550){

$('#well').fadeOut();

}

el.style.webkitTransform = 'translateX(' + curX + 'px)';

}, false);

$('#slider')[0].addEventListener('touchend', function(event) {

this.style.webkitTransition = '-webkit-transform 0.3s ease-in';

this.addEventListener( 'webkitTransitionEnd', function( event ) { this.style.webkitTransition = 'none'; }, false );

this.style.webkitTransform = 'translateX(0px)';

}, false);

});

相关链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值