果如图:
index.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>纯CSS3实现发光开关切换按钮DEMO演示</title> <link rel="stylesheet" href="style.css" media="screen" type="text/css" /> </head> <body style="background-color: #1c1d1f;"> <div style="text-align:center;clear:both"> <script src="/gg_bd_ad_720x90.js" type="text/javascript"></script> <script src="/follow.js" type="text/javascript"></script> </div> <iframe frameborder="0" scrolling="no" src="index2.html" width="100%" height="500px"></iframe> </body> </html>
index2.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Switch Button #3 - CodePen</title> <link rel="stylesheet" href="style.css" media="screen" type="text/css" /> </head> <body> <label class="button"><input type="checkbox"><span></span><span></span></input></label> <script src="js/index.js"></script> </body> </html>
style.css
*, *:before, *:after { -moz-box-sizing: border-box; box-sizing: border-box; } body { background-color: #1c1d1f; } .button { display: block; width: 400px; height: 120px; position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); background-color: #000000; box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.2) inset; border-radius: 20px; overflow: hidden; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .button span { display: block; position: absolute; top: 6px; width: 194px; height: 108px; background-color: #1c1d1f; -webkit-transition: -webkit-transform 300ms ease, box-shadow 300ms ease; transition: transform 300ms ease, box-shadow 300ms ease; } .button span:before { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); font-family: "Open Sans"; font-weight: 800; font-size: 48px; -webkit-transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms; transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms; } .button span:after { content: ""; width: 4px; height: 108px; position: absolute; top: 0; background: -webkit-radial-gradient(center, ellipse, rgba(255, 255, 255, 0.5) 0%, transparent 50%); background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.5) 0%, transparent 50%); -webkit-transition: opacity 300ms ease; transition: opacity 300ms ease; } .button span:first-of-type { left: 6px; border-top-left-radius: 18px; border-bottom-left-radius: 18px; -webkit-transform-style: preserve3d; transform-style: preserve3d; -webkit-transform-origin: right center; -ms-transform-origin: right center; transform-origin: right center; -webkit-transform: perspective(2000px) rotateY(40deg); transform: perspective(2000px) rotateY(40deg); box-shadow: -1px 0 1px rgba(255, 255, 255, 0.1) inset, 4px 0 8px rgba(255, 255, 255, 0.1) inset, 1px 0 0 rgba(255, 255, 255, 0.1) inset, -10px 0 8px rgba(40, 42, 44, 0.9), -20px 0 8px rgba(28, 29, 31, 0.7), -30px 0 8px rgba(28, 29, 31, 0.4); } .button span:first-of-type:before { content: "ON"; color: rgba(0, 0, 0, 0.5); text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 #000000, 1px 4px 6px #1c1d1f; } .button span:first-of-type:after { left: -1px; } .button span:last-of-type { right: 6px; border-top-right-radius: 18px; border-bottom-right-radius: 18px; -webkit-transform-origin: left center; -ms-transform-origin: left center; transform-origin: left center; box-shadow: -1px 1px 1px rgba(255, 255, 255, 0.1) inset, 2px 0 2px rgba(255, 255, 255, 0.05) inset; } .button span:last-of-type:before { content: "OFF"; color: #ff4847; text-shadow: 0 0 24px rgba(255, 72, 71, 0.6); } .button span:last-of-type:after { right: -1px; opacity: 0; } .button input[type="checkbox"] { display: none; } .button input[type="checkbox"]:checked ~ span:first-of-type { -webkit-transform: none; -ms-transform: none; transform: none; box-shadow: 1px 1px 1px rgba(255, 255, 255, 0.1) inset, -2px 0 2px rgba(255, 255, 255, 0.05) inset; } .button input[type="checkbox"]:checked ~ span:first-of-type:before { color: #93c913; text-shadow: 0 0 24px rgba(147, 201, 19, 0.6); } .button input[type="checkbox"]:checked ~ span:first-of-type:after { opacity: 0; } .button input[type="checkbox"]:checked ~ span:last-of-type { -webkit-transform: perspective(2000px) rotateY(-40deg); transform: perspective(2000px) rotateY(-40deg); box-shadow: 1px 0 1px rgba(255, 255, 255, 0.1) inset, -4px 0 8px rgba(255, 255, 255, 0.1) inset, -1px 0 0 rgba(255, 255, 255, 0.1) inset, 10px 0 8px rgba(40, 42, 44, 0.9), 20px 0 8px rgba(28, 29, 31, 0.7), 30px 0 8px rgba(28, 29, 31, 0.4); } .button input[type="checkbox"]:checked ~ span:last-of-type:before { color: rgba(0, 0, 0, 0.5); text-shadow: 1px 4px 6px #1c1d1f, 0 0 0 #000000, 1px 4px 6px #1c1d1f; } .button input[type="checkbox"]:checked ~ span:last-of-type:after { opacity: 1; }
style.less
@background: #1C1D1F; @button: #1C1D1F; @light-on: #93C913; @light-off: #FF4847; @import url(http://fonts.googleapis.com/css?family=Open+Sans:800); *, *:before, *:after { box-sizing: border-box } body { background-color: @background; } .button { display: block; width: 400px; height: 120px; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: darken(@button, 50%); box-shadow: 0 -1px 0 fade(white, 20%) inset; border-radius: 20px; overflow: hidden; cursor: pointer; -webkit-tap-highlight-color: fade(black, 0%); span { display: block; position: absolute; top: 6px; width: 194px; height: 108px; background-color: @button; transition: transform 300ms ease, box-shadow 300ms ease; &:before { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-family: "Open Sans"; font-weight: 800; font-size: 48px; transition: text-shadow 800ms ease 100ms, color 800ms ease 100ms; } &:after { content: ""; width: 4px; height: 108px; position: absolute; top: 0; background: radial-gradient(ellipse at center, fade(white, 50%) 0%, transparent 50%); transition: opacity 300ms ease; } &:first-of-type { left: 6px; border-top-left-radius: 18px; border-bottom-left-radius: 18px; transform-style: preserve3d; transform-origin: right center; transform: perspective(2000px) rotateY(40deg); box-shadow: -1px 0 1px fade(white, 10%) inset, 4px 0 8px fade(white, 10%) inset, 1px 0 0 fade(white, 10%) inset, -10px 0 8px fade(lighten(@button, 5%), 90%), -20px 0 8px fade(@button, 70%), -30px 0 8px fade(@button, 40%); &:before { content: "ON"; color: fade(black, 50%); text-shadow: 1px 4px 6px @button, 0 0 0 black, 1px 4px 6px @button; } &:after { left: -1px; } } &:last-of-type { right: 6px; border-top-right-radius: 18px; border-bottom-right-radius: 18px; transform-origin: left center; box-shadow: -1px 1px 1px fade(white, 10%) inset, 2px 0 2px fade(white, 5%) inset; &:before { content: "OFF"; color: @light-off; text-shadow: 0 0 24px fade(@light-off, 60%); } &:after { right: -1px; opacity: 0; } } } input[type="checkbox"] { display: none; &:checked ~ span { &:first-of-type { transform: none; box-shadow: 1px 1px 1px fade(white, 10%) inset, -2px 0 2px fade(white, 5%) inset; &:before { color: @light-on; text-shadow: 0 0 24px fade(@light-on, 60%); } &:after { opacity: 0; } } &:last-of-type { transform: perspective(2000px) rotateY(-40deg); box-shadow: 1px 0 1px fade(white, 10%) inset, -4px 0 8px fade(white, 10%) inset, -1px 0 0 fade(white, 10%) inset, 10px 0 8px fade(lighten(@button, 5%), 90%), 20px 0 8px fade(@button, 70%), 30px 0 8px fade(@button, 40%); &:before { color: fade(black, 50%); text-shadow: 1px 4px 6px @button, 0 0 0 #000, 1px 4px 6px @button; } &:after { opacity: 1; } } } } }
内容转至网络,若侵权,联系删除
网页设计工作中,我们可以给很多元素添加发光的动画效果,举几个例子,“输入框”、“文字”、“进度条”等。给这些元素加上的发光特效会让整个网页变得更加炫酷。今天陕西优就业小编就为大家搜集整理了8款炫酷的HTML发光动画,这些都可以用作Web前端开发工作中,可以为你节省很多开发时间。
1.HTML5 Canvas五彩缤纷的3D发光水晶球动画
这是一款基于HTML5 Canvas的超绚丽发光水晶球动画,就像是酒吧里的那种水晶球射灯一样,不停地随机变换射出光线的颜色,给人一种非常动感的视觉效果。整个水晶球是在Canvas画布上绘制而成,利用CSS3的相关特性使其能够出现五彩缤纷的发光动画,而且可以通过鼠标滚轮来放大缩小这个水晶球,不得不说HTML5真的是非常强大。
2.jQuery/CSS3实现漂亮字体发光特效
今天我们要来分享一款很酷的jQuery/CSS3文字发光特效,首先是加载了谷歌的公共字体库,因此字体非常特别和漂亮,另外利用了jQuery和CSS3的相关特性,当鼠标滑过文字时,文字将会出现发光的动画特效,非常漂亮。
3.超绚丽CSS3多色彩发光立方体旋转动画
之前我们分享过几个不错的CSS3立方体动画,比如这款HTML5 3D立方体旋转动画和HTML5 3D立方体图片切换动画。今天要分享的也是一款基于CSS3的3D立方体旋转动画,不同的是,这款立方体的每一个面都有不同的色彩,并且会带有绚丽的发光特效。
4.纯CSS3实现发光开关切换按钮
前段时间我们向大家分享过一款牛奶般剔透的CSS3 3D开关按钮,效果相当赞。今天我们要来分享一款类似的纯CSS3发光开关切换按钮,它的外观就像一个电灯的开关,可以左右切换。另外开关上的文字还有发光的特效,整体看上去很有立体感。
5.纯CSS3和SVG鼠标滑过灯泡发光特效
这次要分享一款利用纯CSS3和SVG实现的灯泡发光效果,我们只需要将鼠标滑过灯泡,整个灯泡就会出现发光发亮的动画特效,效果相当逼真。CSS3的运用,让灯泡外围有一层淡淡的光晕。并且在灯光点亮和熄灭的时候有淡入淡出的效果。
6.HTML5 Canvas发光Loading动画
之前我们分享过很多基于CSS3的Loading动画效果,相信大家都很喜欢。今天我们要来分享一款基于HTML5 Canvas的发光Loading加载动画特效。Loading旋转图标是在canvas画布上绘制的,整个loading动画是发光3D的视觉效果,HTML5非常强大。
7.CSS3发光Loading加载动画
今天我们要分享一款与众不同的CSS3 Loading动画效果,它是由几个不同的动画效果组合而成的,像文字打印效果、发光效果、飞入飞出效果,这几种效果都非常酷。另外我们可以再回顾一下其他的CSS3 Loading效果:HTML5 Canvas实现超酷Loading动画、很有个性的CSS3弹跳Loading动画。
8.纯CSS3实现发光动画按钮特效
这是一款基于纯CSS3的发光按钮,按钮发光的颜色是随机的,这样一排按钮就显得五彩缤纷,非常绚丽。之前我们也介绍过不少样式很独特的CSS3按钮,比如纯CSS3 3D开关按钮、纯CSS3实现动感弹性按钮等,都非常不错,也有HTML5动画按钮,大家可以自己看看。
陕西优就业:http://www.ujiuye.com/shaanxi/
IT学习交流:468910291
132个特效,是我历时10个多月在油管一个一个跟着敲出来的,为了加强记忆,每个练习,我都录制了视频,在这里分享出来给大家。大家可能又会调侃了,你是工作不饱和吧,有时间做这些。其实,我目前工作还是挺饱和的,都是挤出来的。我们是9点上班,我基本7点半就到公司自学了,这样我就有一个半小时的时间来做这些了。
对于 CSS 评价,无论是在论坛还是身边的人,我听到最多的是学 CSS 这些花里胡哨没啥用,实际项目中又用不到。听到这些心里还是挺实受挫的,有时候会怀疑自己,我学习的方向是不是错了。但在几次的项目需要用到一些特效,我都能很快的找到思路并做出来,我想这是得益于,我平时所学的这些特效积累出来的。
现在我不在困惑我所学的东西,因为学习成长是你自己事情,而不是别人在意的眼光。
对应的所有视频可以到 【B站查看】,或者在 B 站搜索 前端小智 即可看到,源码都在视频简介里面,大家进行查看。
效果:
视频地址:https://www.bilibili.com/video/BV17V411r74q/
效果:
频地址:https://www.bilibili.com/video/BV16Z4y1u7NY/
效果:
视频地址:https://www.bilibili.com/video/BV1dK411J7p2/
效果:
视频地址:https://www.bilibili.com/video/BV1bA411Y7UY/
演示视频:https://www.bilibili.com/video/BV1Mh411Z7Ze/
演示视频:https://www.bilibili.com/video/BV16f4y1X7Yr/
视频地址:https://www.bilibili.com/video/BV14A411Y7Gd/
视频地址:https://www.bilibili.com/video/BV1oD4y1U7C8/
视频地址:https://www.bilibili.com/video/BV1vT4y157Up/
视频地址:https://www.bilibili.com/video/BV1tf4y1979Z/
视频地址:https://www.bilibili.com/video/BV1EV411U7fD/
视频地址:https://www.bilibili.com/video/BV1sA411n7us/
视频地址:https://www.bilibili.com/video/BV1eZ4y1K7o3/
视频地址:https://www.bilibili.com/video/BV1tK4y1Y771/
视频地址:https://www.bilibili.com/video/BV1V5411h7iZ/
视频地址:https://www.bilibili.com/video/BV1Dh41197Lf/
视频地址:https://www.bilibili.com/video/BV145411b7RJ/
视频播放地址:https://www.bilibili.com/video/BV15D4y1m7JG/
视频演示地址:https://www.bilibili.com/video/BV1Lf4y1X7Bm/
视频地址:https://www.bilibili.com/video/BV1YA411n7xu/
视频地址:https://www.bilibili.com/video/BV1vA411E77W/
视频地址:https://www.bilibili.com/video/BV17T4y1A7Vg/
视频地址:https://www.bilibili.com/video/BV1s5411b78Q/
视频地址:https://www.bilibili.com/video/BV1KZ4y1N7nr/
视频地址:https://www.bilibili.com/video/BV1Jf4y1D7Lm/
视频地址:https://www.bilibili.com/video/BV17A411J7RL/
视频地址:https://www.bilibili.com/video/BV1yv411C7NJ/
视频地址:https://www.bilibili.com/video/BV1RV411m7LQ/
视频地址:https://member.bilibili.com/v2#/upload-manager/article
视频地址:https://www.bilibili.com/video/BV1LK411A7X2/
视频地址:https://www.ixigua.com/6882247186009031181/
视频地址:https://www.ixigua.com/6882247186009031181/
视频地址:https://www.ixigua.com/6883784380632793611/
视频地址:https://www.ixigua.com/6885309534483513859/
视频地址:https://www.ixigua.com/6886389124811457032/
视频地址:https://www.ixigua.com/6887878632572715532/
视频地址:https://www.ixigua.com/6888608009556230667/
视频地址:https://www.ixigua.com/6890835336868397572/
视频地址:https://www.ixigua.com/6891580915374359043/
视频地址:https://www.ixigua.com/6893066211257483784/
视频地址:https://www.ixigua.com/6893808422605554183/
视频地址:https://www.ixigua.com/6894533882432094728/
视频地址:https://www.ixigua.com/6897449872975200780/
视频地址:https://www.ixigua.com/6897450763094753800/
视频地址:https://www.ixigua.com/6898262151455048199/
视频地址:https://www.ixigua.com/6899588911862022660/
视频地址:https://www.ixigua.com/6901230535520027143/
视频地址:https://www.ixigua.com/6902344348986262024/
视频地址:https://www.ixigua.com/6903449899006689804/
视频地址:https://www.ixigua.com/6904504548409213454/
视频地址:https://www.ixigua.com/6906066035506414084/
视频地址:https://www.ixigua.com/6906796258489270788/
视频地址:https://www.ixigua.com/6907873173098889731/?&wid_try=1
视频地址: https://www.bilibili.com/video/BV1964y1f7CK/
视频地址:https://www.ixigua.com/6910132650648797699/
视频地址:https://www.ixigua.com/6911265897659400708/
视频地址:https://www.ixigua.com/6911983867603878407/
视频地址:https://www.ixigua.com/6914222592170263053/
视频地址:https://www.ixigua.com/6914589524660224526/
视频地址:https://www.ixigua.com/6915324225184072200/
视频地址:https://www.ixigua.com/6916439319217603085/
视频地址:https://www.ixigua.com/6917189337700368907/
视频地址:https://www.ixigua.com/6917930699139842563
视频地址:https://www.ixigua.com/6919046116382081540
完~,我是小智,我要去刷碗了,我们下期再见!
*请认真填写需求信息,我们会在24小时内与您取得联系。