整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:

HTML+CSS+JS发光开关按钮

果如图:

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 站搜索 前端小智 即可看到,源码都在视频简介里面,大家进行查看。

67.信号故障特效

效果:

视频地址:https://www.bilibili.com/video/BV17V411r74q/

68.自定义动态复选框

效果:

频地址:https://www.bilibili.com/video/BV16Z4y1u7NY/

69.创意div盒设计

效果:

视频地址:https://www.bilibili.com/video/BV1dK411J7p2/

70.SVG弹性线条动画特效

效果:

视频地址:https://www.bilibili.com/video/BV1bA411Y7UY/

71.类似望花筒特效

演示视频:https://www.bilibili.com/video/BV1Mh411Z7Ze/

72.刮刮乐特效

演示视频:https://www.bilibili.com/video/BV16f4y1X7Yr/

73.使用HTML CSS和jQuery进行水平页面滚动

视频地址:https://www.bilibili.com/video/BV14A411Y7Gd/

74.CSS Clip-path 鼠标移动特效

视频地址:https://www.bilibili.com/video/BV1oD4y1U7C8/

75. 让面部表情跟着鼠标光标变化

视频地址:https://www.bilibili.com/video/BV1vT4y157Up/

76.星星闪烁特效

视频地址:https://www.bilibili.com/video/BV1tf4y1979Z/

77.CSS渐变按钮悬停效果

视频地址:https://www.bilibili.com/video/BV1EV411U7fD/

78.聚光灯特效(JQuery鼠标移动特效)


视频地址:https://www.bilibili.com/video/BV1sA411n7us/


79.3D视频立方体特效


视频地址:https://www.bilibili.com/video/BV1eZ4y1K7o3/


80.3D背景动画效果


视频地址:https://www.bilibili.com/video/BV1tK4y1Y771/


81.滑块百分比的有趣应用

视频地址:https://www.bilibili.com/video/BV1V5411h7iZ/

82.纯CSS液体加载特效

视频地址:https://www.bilibili.com/video/BV1Dh41197Lf/

83.CSS悬停效果(只是为了好玩)

视频地址:https://www.bilibili.com/video/BV145411b7RJ/

84.CSS 3D波浪加载特效

视频播放地址:https://www.bilibili.com/video/BV15D4y1m7JG/

85.CSS水波背景动画特效

视频演示地址:https://www.bilibili.com/video/BV1Lf4y1X7Bm/

86.CSS加载文本动画特效

视频地址:https://www.bilibili.com/video/BV1YA411n7xu/

87.服务条款的一种展示特效

视频地址:https://www.bilibili.com/video/BV1vA411E77W/

88.幽灵文字特效

视频地址:https://www.bilibili.com/video/BV17T4y1A7Vg/

89.破碎的玻璃横幅


视频地址:https://www.bilibili.com/video/BV1s5411b78Q/

90.CSS列表项悬停特效

视频地址:https://www.bilibili.com/video/BV1KZ4y1N7nr/

91.方向感应卡悬停效果

视频地址:https://www.bilibili.com/video/BV1Jf4y1D7Lm/

92.发光文字加载特效

视频地址:https://www.bilibili.com/video/BV17A411J7RL/

93.砖石旋转背景动画特效

视频地址:https://www.bilibili.com/video/BV1yv411C7NJ/

94.文字悬停分割特效

视频地址:https://www.bilibili.com/video/BV1RV411m7LQ/

95.按钮涟漪特效

视频地址:https://member.bilibili.com/v2#/upload-manager/article

96.魔幻的滚动视差特效

视频地址:https://www.bilibili.com/video/BV1LK411A7X2/

97.炫酷加载特效(模拟手机信号)

视频地址:https://www.ixigua.com/6882247186009031181/

98.炫酷发光特效

视频地址:https://www.ixigua.com/6882247186009031181/

99.仙境特效

视频地址:https://www.ixigua.com/6883784380632793611/


100.模拟播放暂时特效

视频地址:https://www.ixigua.com/6885309534483513859/

101.新拟物渐变加载特效

视频地址:https://www.ixigua.com/6886389124811457032/

102.使用Vanilla lift.js实现3D视差倾斜效果

视频地址:https://www.ixigua.com/6887878632572715532/

103.3D书籍模型

视频地址:https://www.ixigua.com/6888608009556230667/

104.打工人的撕裂方式

视频地址:https://www.ixigua.com/6890835336868397572/

105.液体流加载特效

视频地址:https://www.ixigua.com/6891580915374359043/

106.创意视频球特效


视频地址:https://www.ixigua.com/6893066211257483784/


107.CSS响应卡片悬停特效

视频地址:https://www.ixigua.com/6893808422605554183/

108.使用Grade.Js自动生成渐变背景颜色


视频地址:https://www.ixigua.com/6894533882432094728/

109.现代CSS按钮悬停效果

视频地址:https://www.ixigua.com/6897449872975200780/

110.无限叠卡特效

视频地址:https://www.ixigua.com/6897450763094753800/

111.使用CSS进行彩色烟雾视频和文本处理

视频地址:https://www.ixigua.com/6898262151455048199/

112.使用 sketch.js 实现彗星特效

视频地址:https://www.ixigua.com/6899588911862022660/

113.文字肖像特效

视频地址:https://www.ixigua.com/6901230535520027143/

114.使用SVG filter创建粘糊糊效果

视频地址:https://www.ixigua.com/6902344348986262024/

115.滑动菜单指示器特效

视频地址:https://www.ixigua.com/6903449899006689804/

117.纯CSS 和 JS 实现泡泡特效

视频地址:https://www.ixigua.com/6904504548409213454/

118.CSS3按钮悬停闪亮特效

视频地址:https://www.ixigua.com/6906066035506414084/

119.css按钮边框渐变发光特效

视频地址:https://www.ixigua.com/6906796258489270788/

120.如何使用 JS 动态更新CSS变量

视频地址:https://www.ixigua.com/6907873173098889731/?&wid_try=1

121.使用gsap scrollTrigger滚动触发CSS动画

视频地址: https://www.bilibili.com/video/BV1964y1f7CK/

122.为你的博客和网站设计一个简单的日历

123.火箭发射特效

视频地址:https://www.ixigua.com/6910132650648797699/

124.酷炫box-shadow 悬停特效

视频地址:https://www.ixigua.com/6911265897659400708/

125.如何使用 JS 实现背景视差特效

视频地址:https://www.ixigua.com/6911983867603878407/

126.如何使用CSS和 JS 创建简单图片切换

视频地址:https://www.ixigua.com/6914222592170263053/

127.CSS 图标魔法线悬停特效

视频地址:https://www.ixigua.com/6914589524660224526/

128.落叶飘舞动画特效

视频地址:https://www.ixigua.com/6915324225184072200/

129.好家伙,女朋友让我用前端人的方式,描述一下一幅画被墨水洒的到样子

视频地址:https://www.ixigua.com/6916439319217603085/

130. HTML+CSS完成苹果logo加载效果,好家伙,还不收藏一波!

视频地址:https://www.ixigua.com/6917189337700368907/

131.手撸一个跑马灯加载特效送给前端女朋友

视频地址:https://www.ixigua.com/6917930699139842563

132.前端人,来,给沾满雾气的玻璃刮一刮,好家伙,这工具超好用!

视频地址:https://www.ixigua.com/6919046116382081540

完~,我是小智,我要去刷碗了,我们下期再见!