html5点击展开动画效果,jquery展开收缩扑克牌动画效果教程

Baraja是一个很有趣的jQuery插件。它允许你像在桌子上摊开扑克牌一样将元素展开和收缩。它使用CSS transforms来旋转和translate这些元素。它使用几个可用参数来控制各种不同的展开效果,比如横向移动扑克牌并像开扇子一样旋转它们。

注意:不是每一个浏览器都支持CSS transforms和transitions。

HTML结构:

要使用jquery.Baraja插件,必须使用一个无序列表,并给它一个classbaraja-container。

  • image1

    Coco Loko

    Total bicycle rights in blog four loko raw denim ex, helvetica sapiente odio placeat.

调用插件:

$( '#baraja-el' ).baraja();

下面是一个使用了参数的例子:

$( '#some-button' ).on( 'click', function( event ) {

baraja.fan( {

speed : 500,

easing : 'ease-out',

range : 90,

direction : 'right',

origin : { x : 25, y : 100 },

center : true,

translation : 0

} );

} );

可选参数

下面列出了可用的默认参数:

$.Baraja.defaults = {

// if we want to specify a selector that triggers the next() function. example: '#baraja-nav-next'

nextEl : '',

// if we want to specify a selector that triggers the previous() function

prevEl : '',

// default transition speed

speed : 300,

// default transition easing

easing : 'ease-in-out'

};

可用的方法有:fan(), next(), previous(), close(), add()

将扑克牌设置为扇形的方法如下:

this.fanSettings = {

// speed for opening/closing

speed : 500,

// easing for opening/closing

easing : 'ease-out',

// difference/range of possible angles that the items will have

// example: with range:90 and center:false the first item

// will have 0deg and the last one 90deg;

// if center:true, then the first one will have 45deg

// and the last one -45deg; in both cases the difference is 90deg

range : 90,

// this defines the position of the first item

// (to the right, to the left)

// and its angle (clockwise / counterclockwise)

direction : 'right',

// transform origin:

// you can also pass a minX and maxX, meaning the left value

// will vary between minX and maxX

origin : { x : 25, y : 100 },

// additional translation of each item

translation : 0,

// if the cards should be centered after the transform

// is applied

center : true,

// add a random factor to the final transform

scatter : false

};

基本的样式都写在baraja.css文件中。

在下载包中列举了许多不同的例子,你可以下载来研究他们。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我理解了你的问题。HTML5卷轴展开动画和古卷轴平滑打开jQuery动画特效是两种不同的效果,我可以为你介绍一些实现这两种效果的方法。 首先,HTML5卷轴展开动画可以使用CSS3的transition属性和transform属性来实现。你可以将卷轴的内容放在一个div中,然后设置div的高度为0,再添加一个hover事件,当卷轴被hover时,将div的高度设置为其内容的高度,并且添加一个transform:rotateX(90deg)的属性,使其像卷轴展开一样。 其次,古卷轴平滑打开jQuery动画特效可以使用jQuery动画效果来实现。你可以将卷轴的内容放在一个div中,然后使用jQuery的animate方法,逐步将div的高度从0变为其内容的高度,并且添加一个rotateX的属性,使其像卷轴展开一样。 这两种效果的具体实现可以参考以下代码: HTML5卷轴展开动画: ``` <style> .scroll { height: 0; overflow: hidden; transition: height 0.5s ease-in-out, transform 0.5s ease-in-out; transform-origin: top; } .scroll:hover { height: auto; transform: rotateX(90deg); } </style> <div class="scroll"> <!-- 卷轴内容 --> </div> ``` 古卷轴平滑打开jQuery动画特效: ``` <style> .scroll { height: 0; overflow: hidden; transform-origin: top; } </style> <script> $(document).ready(function() { $(".scroll").hover(function() { $(this).animate({ height: $(this).get(0).scrollHeight, rotateX: "90deg" }, 500); }, function() { $(this).animate({ height: 0, rotateX: "0deg" }, 500); }); }); </script> <div class="scroll"> <!-- 卷轴内容 --> </div> ``` 希望这些代码对你有所帮助。如果你有任何问题,请随时问我。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值