一款利用纯css3实现的360度翻转按钮的实例教程
程序员文章站
2022-06-26 10:15:16
这篇文章主要为大家介绍了利用纯css3实现的翻转360动画按钮的方法,代码简单易懂,实现出来的效果却很美观,需要的朋友可以过来复制代码,顺便学习一下... 14-11-05...
今天要给大家分享的是由css3实现的翻转360动画按钮。之前已为大家分享了好几款css3按钮,大家可以点击链接进去找一找适合自己的。哈哈。下面先为大家上效果图:
下面是实现的代码。
html代码:
xml/html code复制内容到剪贴板
- <ul class="flatflipbuttons">
- <li><a href="https://www.jb51.net" title="search"><span class="icon-search"></span>
- </a><b>search</b></li>
- <li><a href="https://www.jb51.net"><span class="icon-gears"></span></a><b>gears</b></li>
- <li><a href="https://www.jb51.net"><span class="icon-rss"></span></a><b>rss</b></li>
- <li><a href="https://www.jb51.net"><span class="icon-twitter"></span></a><b>twitter</b></li>
- <li><a href="https://www.jb51.net"><span class="icon-rocket"></span></a><b>rocket</b></li>
- </ul>
- <br />
- <br />
- <ul class="flatflipbuttons second">
- <li><a href="https://www.jb51.net"><span>
- <img src="imgs/rss-heart.png" /></span></a></li>
- <li><a href="https://www.jb51.net"><span>
- <img src="imgs/twitter-heart.png" /></span></a></li>
- <li><a href="https://www.jb51.net"><span>
- <img src="imgs/facebook-heart.png" /></span></a></li>
- <li><a href="https://www.jb51.net"><span>
- <img src="imgs/google-heart.png" /></span></a></li>
- <li><a href="https://www.jb51.net"><span>
- <img src="imgs/stumble-heart.png" /></span></a></li>
- </ul>
css代码:
css code复制内容到剪贴板
- ul.flatflipbuttons
- {
- margin: 0;
- padding: 0;
- list-style: none;
- -webkit-perspective: 10000px; /* larger the value, the less pronounced the 3d effect */
- -moz-perspective: 10000px;
- perspective: 10000px;
- }
- ul.flatflipbuttons li
- {
- margin: 0;
- display: inline-block;
- width: 100px; /* dimensions of buttons. */
- height: 100px;
- margin-right: 15px; /* spacing between buttons */
- background: white;
- text-transform: uppercase;
- text-align: center;
- }
- ul.flatflipbuttons li a
- {
- display: table;
- font: bold 36px arial; /* font size, pertains to icon fonts specifically */
- width: 100%;
- height: 100%;
- margin-bottom: 4px;
- color: black;
- background: #3b9dd5;
- text-decoration: none;
- outline: none;
- -webkit-transition: all 300ms ease-out; /* css3 transition. last value is pause before transition play */
- -moz-transition: all 300ms ease-out;
- transition: all 300ms ease-out;
- }
- ul.flatflipbuttons li:nth-of-type(1) a
- {
- color: white;
- background: #3b9dd5;
- }
- ul.flatflipbuttons li:nth-of-type(2) a
- {
- background: #a1cd3a;
- }
- ul.flatflipbuttons li:nth-of-type(3) a
- {
- background: #80c5ec;
- }
- ul.flatflipbuttons li:nth-of-type(4) a
- {
- color: white;
- background: #635746;
- }
- ul.flatflipbuttons li:nth-of-type(5) a
- {
- background: #f2c96d;
- }
- ul.flatflipbuttons li a span
- {
- -moz-box-sizing: border-box;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- display: table-cell;
- vertical-align: middle;
- width: 100%;
- height: 100%;
- -webkit-transition: all 300ms ease-out; /* css3 transition. */
- -moz-transition: all 300ms ease-out;
- transition: all 300ms ease-out;
- }
- ul.flatflipbuttons li b
- {
- /* css for text beneath button */
- display: block;
- position: relative;
- width: 100%;
- opacity: 0;
- -webkit-transition: all 300ms ease-out 0.2s; /* css3 transition. 0.2s delay */
- -moz-transition: all 300ms ease-out 0.2s;
- transition: all 300ms ease-out 0.2s;
- }
- ul.flatflipbuttons li a img
- {
- /* css for image if defined inside button */
- border-width: 0;
- vertical-align: middle;
- }
- ul.flatflipbuttons li:hover a
- {
- -webkit-transform: rotatey(180deg); /* flip horizontally 180deg*/
- -moz-transform: rotatey(180deg);
- transform: rotatey(180deg);
- background: #c1e4ec; /* bgcolor of button onmouseover*/
- -webkit-transition-delay: 0.2s;
- -moz-transition-delay: 0.2s;
- transition-delay: 0.2s;
- }
- ul.flatflipbuttons li:hover a span
- {
- color: black; /* color of icon font onmouseover */
- -webkit-transform: rotatey(180deg);
- -moz-transform: rotatey(180deg); /* flip horizontally 180deg*/
- transform: rotatey(180deg);
- -webkit-transition-delay: 0.2s;
- -moz-transition-delay: 0.2s;
- transition-delay: 0.2s;
- }
- ul.flatflipbuttons li:hover b
- {
- opacity: 1;
- }
- /* css for 2nd menu below specifically */
- ul.second li a
- {
- background: #eee !important;
- }
- ul.second li a:hover
- {
- background: #ddd !important;
- }
以上就是利用css3实现的翻转360动画按钮的代码教程,谢谢阅读,希望能帮到大家,请继续关注,我们会努力分享更多优秀的文章。