博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mootools_使用MooTools创建动画滑动按钮
阅读量:2517 次
发布时间:2019-05-11

本文共 3379 字,大约阅读时间需要 11 分钟。

mootools

MooTools Sliding Button

Buttons (or links) are usually the elements on our sites that we want to draw a lot of attention to. Unfortunately many times they end up looking the most boring. You don't have to let that happen though! I recently found a which provided a great method for making button have an unexpected pop. Here's a quick tutorial on how to duplicate that look using MooTools.

按钮(或链接)通常是我们要吸引很多注意力的站点上的元素。 不幸的是,很多时候他们最终看起来最无聊。 不过,您不必让这种情况发生! 我最近发现了一个 ,该提供了一种使按钮产生意外弹出的好方法。 这是有关如何使用MooTools复制外观的快速教程。

HTML (The HTML)

 

The system works off of one DIV, two As and SPAN elements. Note the IDs and CSS classes for the CSS.

该系统基于一个DIV,两个As和SPAN元素工作。 注意CSS的ID和CSS类。

CSS (The CSS)

.button_wrap{ position:relative; width:225px; height:36px; overflow:hidden; font-weight:bold; font-size:11px; margin:10px; }.button_aLeft{ width:70px; height:36px; -moz-border-radius:20px; -webkit-border-radius:20px; background-color:#093d6f; color:#fff; top:0px; right:0px; position:absolute; line-height:36px; text-align:left; }.button_aLeft span{ /* display:none; */ visibility:hidden; padding-left:20px; color:#fff; }.button_aRight{ width:70px; height:36px; -moz-border-radius:20px; -webkit-border-radius:20px; background-color:#093d6f; color:#fff; top:0px; left:0px; position:absolute; line-height:36px; text-align:right; }.button_aRight span{ /* display:none; */ visibility:hidden; padding-right:20px; color:#fff; }.button_bLeft{ width:64px; height:30px; background-color:#fff; -moz-border-radius:20px; -webkit-border-radius:20px; color:#000; position:absolute; top:3px; right:3px; text-transform:uppercase; line-height:30px; text-align:center; cursor:pointer; }.button_bLeft span{ color:#008ddd; }.button_bRight{ width:64px; height:30px; background-color:#fff; -moz-border-radius:20px; -webkit-border-radius:20px; color:#000; position:absolute; top:3px; left:3px; text-transform:uppercase; line-height:30px; text-align:center; cursor:pointer; }.button_bRight span{ color:#008ddd; }.button_c{ background-color:#008ddd; color:#fff; text-transform:uppercase; }.button_c span{ color:#093d6f; }

The CSS code above mirrors the original code with the exception that "display:none;" was changed to "visibility:hidden", per the differences in MooTools and jQuery fading methodology. Feel free to modify the basic color/formatting styles in any way you'd like.

上面CSS代码反映了原始代码,但“ display:none;”例外。 根据MooTools和jQuery淡入方法的差异,更改为“ visibility:hidden”。 随时以您想要的任何方式修改基本的颜色/格式样式。

MooTools JavaScript (The MooTools JavaScript)

window.addEvent('domready',function() {	$$('.slidebttn').each(function(btn) {		var prev = btn.getPrevious('a').set('tween',{ duration: 200 });		var span = prev.getElement('span');		btn.addEvents({			mouseenter: function(e) { 				btn.addClass('button_c');				prev.tween('width',225);				span.fade('in');			},			mouseleave:function(e) {				btn.removeClass('button_c');				prev.tween('width',70);				span.fade('out');			}		});	});});

The first step is grabbing all button containers and identifying the SPAN and A elements within them. Then we add mouseenter and mouseleave events to the container which do the animation of the primary A/SPAN elements.

第一步是抓取所有按钮容器并标识其中的SPAN和A元素。 然后,我们将mouseenter和mouseleave事件添加到容器中,以对主要A / SPAN元素进行动画处理。

Great work by Tympanus. The effect is classy and well executed. Now go and use this on your next project!

鼓膜的伟大工作。 效果是一流的,执行得很好。 现在开始在下一个项目中使用它!

翻译自:

mootools

转载地址:http://bvpwd.baihongyu.com/

你可能感兴趣的文章
Alpha版总结会议
查看>>
Java--面试通关要点
查看>>
iOS 消息推送原理
查看>>
随笔1
查看>>
Codeforces 731 C.Socks-并查集+STL(vector+map)
查看>>
洛谷 P3383 【模板】线性筛素数-线性筛素数(欧拉筛素数)O(n)基础题贴个板子备忘...
查看>>
C语言中的正负数及其输出以及小数
查看>>
Android Fragments 详细使用
查看>>
【转】MySQL-Utilities,mysql工具包
查看>>
使用echarts实现了一个折现图,数据是一天24小时
查看>>
杂项:game_navigation
查看>>
建站手册-职业规划:职业资源
查看>>
基于 Generator 和 Iterator 的惰性列表
查看>>
身为前端开发工程师,你需要了解的搜索引擎优化SEO.
查看>>
一篇文章掌握nightwatch自动化测试
查看>>
vue 上传图片到阿里云(前端直传:不推荐)
查看>>
求最大区间,使得特定的两个数的个数相等
查看>>
node读写Excel操作
查看>>
双飞翼布局
查看>>
android利用wireshark抓包
查看>>