美味的CSS动画汉堡包:hamburgers_html/css_WEB-ITnose
Hamburgers is a collection of tasty CSS-animated hamburger icons. Also included is the source as a Sass library. It’s modular and customizable, so cook up your own hamburger.
Table of Contents
- Usage
- Customization
- Accessibility
- Browser Support
Usage
Download and include the CSS in the
of your site:
Add the base hamburger markup:
You can use
Append the class name of the type of hamburger you’re craving:
Here’s the list of hamburger-type classes you can choose from:
hamburger--arrowhamburger--arrow-rhamburger--arrowalthamburger--arrowalt-rhamburger--boringhamburger--collapsehamburger--collapse-rhamburger--elastichamburger--elastic-rhamburger--emphatichamburger--emphatic-rhamburger--sliderhamburger--slider-rhamburger--spinhamburger--spin-rhamburger--squeezehamburger--vortexhamburger--vortex-r
Note: -r classes are reverse variants (e.g. hamburger--spin spins clockwise whereas hamburger--spin-r spins counterclockwise.
Trigger the active state by appending class name is-active:
Since the class name would have to be toggled via JavaScript and implementation would differ based on the context of how you plan on using the hamburger, I’m going to leave the rest up to you.
Sass
I’ve also included .scss source files if you use Sass as your CSS precompiler. It’s customizable and modular.
Import the hamburgers.scss file in your Sass manifest file:
@import "path/to/hamburgers";
Customize your hamburger and/or remove any types you don’t want in hamburgers.scss.
Hamburgers is also available on npm and Bower.
npm install hamburgersbower install css-hamburgers
* Be sure to run the CSS through Autoprefixer since the Sass doesn’t account for vendor prefixes.
Customization
Here is the full list of default settings (found in _sass/hamburgers/hamburgers.scss);
$hamburger-padding-x : 15px !default;$hamburger-padding-y : 15px !default;$hamburger-layer-width : 40px !default;$hamburger-layer-height : 4px !default;$hamburger-layer-spacing : 6px !default;$hamburger-layer-color : #000 !default;$hamburger-layer-border-radius : 4px !default;$hamburger-hover-opacity : 0.7 !default;$hamburger-hover-transition-duration : 0.15s !default;$hamburger-hover-transition-timing-function: linear !default;// To use CSS filters as the hover effect instead of opacity,// set $hamburger-hover-use-filter as true and// change the value of $hamburger-hover-filter accordingly.$hamburger-hover-use-filter: false !default;$hamburger-hover-filter : opacity(50%) !default;
To override any default settings, you can change the value(s) within hamburgers.scss, but I recommend you declare your new settings separately:
@import "path/to/hamburgers";$hamburgers-padding-x: 20px;$hamburgers-padding-y: 15px;
You can also create a separate file (e.g. hamburgers-settings.scss) with those declarations, then import it along with Hamburgers:
@import "path/to/hamburgers";@import "hamburgers-settings"
ems or rems
Wanna work with ems or rems instead of px? Just change all the px values to the unit of your choice. Note: Be consistent (all px or all ems), otherwise it may break—the math behind the customization will fail if it attempts to perform operations with values of different units.
Not satisfied?
Dig into _base.scss or types/ and customize to your heart’s content. Fair warning: It‘s pretty delicate and may break, especially if you tweak the animations themselves.
Accessibility
Hamburger menu icons can be useful in the right context, but they’re not the most accessible.
ARIA will help make it accessible to people with disabilities.
If you insist on using
A label can help make it more obvious that it toggles a menu.
Here are some resources on web accessibility and ARIA.
Browser Support
Animations use CSS3 3D transforms (translate3d whenever possible for GPU acceleration), which is supported by most browsers (not supported by IE9 and older and Opera Mini). For detailed browser support, check caniuse.com.
项目地址: https://github.com/jonsuh/hamburgers
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
相关文章
相关视频
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
上一篇: Server 2008 R2的十大特性
推荐阅读
-
一款简洁的纯css3代码实现的动画导航_html/css_WEB-ITnose
-
一款纯css3实现的机器人看书动画效果_html/css_WEB-ITnose
-
8套迷人精致的CSS3 3D按钮动画_html/css_WEB-ITnose
-
如何使用SVG生成超酷的页面预加载素描动画效果_html/css_WEB-ITnose
-
一款简洁的纯css3代码实现的动画导航_html/css_WEB-ITnose
-
基于CSS3制作的鼠标悬停动画菜单_html/css_WEB-ITnose
-
Css 动画的回调_html/css_WEB-ITnose
-
使用jQuery timelinr和animate.css创建超酷的CSS动画时间轴特效_html/css_WEB-ITnose
-
赞!超炫的页面切换动画效果【附源码下载】_html/css_WEB-ITnose
-
CSS秘密花园: 沿着路径的动画_html/css_WEB-ITnose
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论