CSS3制作炫酷的自定义发光文字

秋天的人们是勤劳的。人们忙着摘果实、收稻谷,脸上挂满了丰收的喜悦。

本文为大家分享一款基于纯CSS3的文字发光特效,当我们将鼠标滑过文字时,文字就会模拟发光动画,展现出非常酷的发光画面。另外,由于引用了特殊字体,所以整个文字效果看起来有着3D立体的特效,如果你的网络无法加载这些字体,可能是由于国外的这个网站被墙的缘故,就像google的字体库网址被屏蔽那样。

HTML代码

XML/HTML Code复制内容到剪贴板
  1. <divid="container">
  2. <p><arel="nofollow noopener noreferrer" href="#">
  3. RED
  4. </a></p>
  5. <p><arel="nofollow noopener noreferrer" href="#">
  6. BLUE
  7. </a></p>
  8. <p><arel="nofollow noopener noreferrer" href="#">
  9. Yellow
  10. </a></p>
  11. <p><arel="nofollow noopener noreferrer" href="#">
  12. GREEN
  13. </a></p>
  14. <p><arel="nofollow noopener noreferrer" href="#">
  15. ORANGE
  16. </a></p>
  17. <p><arel="nofollow noopener noreferrer" href="#">
  18. VIOLET
  19. </a></p>
  20. </div>

CSS代码

CSS Code复制内容到剪贴板
  1. /*setup*/
  2. *{
  3. margin:0;
  4. padding:0;
  5. }
  6. @font-face{
  7. font-family:'Monoton';
  8. font-style:normal;
  9. font-weight:400;
  10. src:local('Monoton'),local('Monoton-Regular'),url(http://themes.googleusercontent.com/static/fonts/monoton/v4/AKI-lyzyNHXByGHeOcds_w.woff)format('woff');
  11. }
  12. @font-face{
  13. font-family:'Iceland';
  14. font-style:normal;
  15. font-weight:400;
  16. src:local('Iceland'),local('Iceland-Regular'),url(http://themes.googleusercontent.com/static/fonts/iceland/v3/F6LYTZLHrG9BNYXRjU7RSw.woff)format('woff');
  17. }
  18. @font-face{
  19. font-family:'Pacifico';
  20. font-style:normal;
  21. font-weight:400;
  22. src:local('PacificoRegular'),local('Pacifico-Regular'),url(http://themes.googleusercontent.com/static/fonts/pacifico/v5/yunJt0R8tCvMyj_V4xSjafesZW2xOQ-xsNqO47m55DA.woff)format('woff');
  23. }
  24. @font-face{
  25. font-family:'PressStart';
  26. font-style:normal;
  27. font-weight:400;
  28. src:local('PressStart2P'),local('PressStart2P-Regular'),url(http://themes.googleusercontent.com/static/fonts/pressstart2p/v2/8Lg6LX8-ntOHUQnvQ0E7o3dD2UuwsmbX3BOp4SL_VwM.woff)format('woff');
  29. }
  30. @font-face{
  31. font-family:'Audiowide';
  32. font-style:normal;
  33. font-weight:400;
  34. src:local('Audiowide'),local('Audiowide-Regular'),url(http://themes.googleusercontent.com/static/fonts/audiowide/v2/8XtYtNKEyyZh481XVWfVOj8E0i7KZn-EPnyo3HZu7kw.woff)format('woff');
  35. }
  36. @font-face{
  37. font-family:'VampiroOne';
  38. font-style:normal;
  39. font-weight:400;
  40. src:local('VampiroOne'),local('VampiroOne-Regular'),url(http://themes.googleusercontent.com/static/fonts/vampiroone/v3/Ho2Xld8UbQyBA8XLxF1_NYbN6UDyHWBl620a-IRfuBk.woff)format('woff');
  41. }
  42. body{
  43. background-color:#222222;
  44. }
  45. #container{
  46. margin:auto;
  47. }
  48. /*neeeeoooon*/
  49. p{
  50. text-align:center;
  51. font-size:7em;
  52. margin:20px020px0;
  53. }
  54. a{
  55. text-decoration:none;
  56. -webkit-transition:all0.5s;
  57. -moz-transition:all0.5s;
  58. transition:all0.5s;
  59. }
  60. p:nth-child(1)a{
  61. color:#FF1177;
  62. font-family:Monoton;
  63. }
  64. p:nth-child(1)a:hover{
  65. -webkit-animation:neon11.5sease-in-outinfinitealternate;
  66. -moz-animation:neon11.5sease-in-outinfinitealternate;
  67. animation:neon11.5sease-in-outinfinitealternate;
  68. }
  69. p:nth-child(2)a{
  70. font-size:1.5em;
  71. color:#228DFF;
  72. font-family:Iceland;
  73. }
  74. p:nth-child(2)a:hover{
  75. -webkit-animation:neon21.5sease-in-outinfinitealternate;
  76. -moz-animation:neon21.5sease-in-outinfinitealternate;
  77. animation:neon21.5sease-in-outinfinitealternate;
  78. }
  79. p:nth-child(3)a{
  80. color:#FFDD1B;
  81. font-family:Pacifico;
  82. }
  83. p:nth-child(3)a:hover{
  84. -webkit-animation:neon31.5sease-in-outinfinitealternate;
  85. -moz-animation:neon31.5sease-in-outinfinitealternate;
  86. animation:neon31.5sease-in-outinfinitealternate;
  87. }
  88. p:nth-child(4)a{
  89. color:#B6FF00;
  90. font-family:PressStart;
  91. font-size:0.8em;
  92. }
  93. p:nth-child(4)a:hover{
  94. -webkit-animation:neon41.5sease-in-outinfinitealternate;
  95. -moz-animation:neon41.5sease-in-outinfinitealternate;
  96. animation:neon41.5sease-in-outinfinitealternate;
  97. }
  98. p:nth-child(5)a{
  99. color:#FF9900;
  100. font-family:Audiowide;
  101. }
  102. p:nth-child(5)a:hover{
  103. -webkit-animation:neon51.5sease-in-outinfinitealternate;
  104. -moz-animation:neon51.5sease-in-outinfinitealternate;
  105. animation:neon51.5sease-in-outinfinitealternate;
  106. }
  107. p:nth-child(6)a{
  108. color:#BA01FF;
  109. font-family:VampiroOne;
  110. }
  111. p:nth-child(6)a:hover{
  112. -webkit-animation:neon61.5sease-in-outinfinitealternate;
  113. -moz-animation:neon61.5sease-in-outinfinitealternate;
  114. animation:neon61.5sease-in-outinfinitealternate;
  115. }
  116. pa:hover{
  117. color:#ffffff;
  118. }
  119. /*glowforwebkit*/
  120. @-webkit-keyframesneon1{
  121. from{
  122. text-shadow:0010px#fff,
  123. 0020px#fff,
  124. 0030px#fff,
  125. 0040px#FF1177,
  126. 0070px#FF1177,
  127. 0080px#FF1177,
  128. 00100px#FF1177,
  129. 00150px#FF1177;
  130. }
  131. to{
  132. text-shadow:005px#fff,
  133. 0010px#fff,
  134. 0015px#fff,
  135. 0020px#FF1177,
  136. 0035px#FF1177,
  137. 0040px#FF1177,
  138. 0050px#FF1177,
  139. 0075px#FF1177;
  140. }
  141. }
  142. @-webkit-keyframesneon2{
  143. from{
  144. text-shadow:0010px#fff,
  145. 0020px#fff,
  146. 0030px#fff,
  147. 0040px#228DFF,
  148. 0070px#228DFF,
  149. 0080px#228DFF,
  150. 00100px#228DFF,
  151. 00150px#228DFF;
  152. }
  153. to{
  154. text-shadow:005px#fff,
  155. 0010px#fff,
  156. 0015px#fff,
  157. 0020px#228DFF,
  158. 0035px#228DFF,
  159. 0040px#228DFF,
  160. 0050px#228DFF,
  161. 0075px#228DFF;
  162. }
  163. }
  164. @-webkit-keyframesneon3{
  165. from{
  166. text-shadow:0010px#fff,
  167. 0020px#fff,
  168. 0030px#fff,
  169. 0040px#FFDD1B,
  170. 0070px#FFDD1B,
  171. 0080px#FFDD1B,
  172. 00100px#FFDD1B,
  173. 00150px#FFDD1B;
  174. }
  175. to{
  176. text-shadow:005px#fff,
  177. 0010px#fff,
  178. 0015px#fff,
  179. 0020px#FFDD1B,
  180. 0035px#FFDD1B,
  181. 0040px#FFDD1B,
  182. 0050px#FFDD1B,
  183. 0075px#FFDD1B;
  184. }
  185. }
  186. @-webkit-keyframesneon4{
  187. from{
  188. text-shadow:0010px#fff,
  189. 0020px#fff,
  190. 0030px#fff,
  191. 0040px#B6FF00,
  192. 0070px#B6FF00,
  193. 0080px#B6FF00,
  194. 00100px#B6FF00,
  195. 00150px#B6FF00;
  196. }
  197. to{
  198. text-shadow:005px#fff,
  199. 0010px#fff,
  200. 0015px#fff,
  201. 0020px#B6FF00,
  202. 0035px#B6FF00,
  203. 0040px#B6FF00,
  204. 0050px#B6FF00,
  205. 0075px#B6FF00;
  206. }
  207. }
  208. @-webkit-keyframesneon5{
  209. from{
  210. text-shadow:0010px#fff,
  211. 0020px#fff,
  212. 0030px#fff,
  213. 0040px#FF9900,
  214. 0070px#FF9900,
  215. 0080px#FF9900,
  216. 00100px#FF9900,
  217. 00150px#FF9900;
  218. }
  219. to{
  220. text-shadow:005px#fff,
  221. 0010px#fff,
  222. 0015px#fff,
  223. 0020px#FF9900,
  224. 0035px#FF9900,
  225. 0040px#FF9900,
  226. 0050px#FF9900,
  227. 0075px#FF9900;
  228. }
  229. }
  230. @-webkit-keyframesneon6{
  231. from{
  232. text-shadow:0010px#fff,
  233. 0020px#fff,
  234. 0030px#fff,
  235. 0040px#ff00de,
  236. 0070px#ff00de,
  237. 0080px#ff00de,
  238. 00100px#ff00de,
  239. 00150px#ff00de;
  240. }
  241. to{
  242. text-shadow:005px#fff,
  243. 0010px#fff,
  244. 0015px#fff,
  245. 0020px#ff00de,
  246. 0035px#ff00de,
  247. 0040px#ff00de,
  248. 0050px#ff00de,
  249. 0075px#ff00de;
  250. }
  251. }
  252. /*glowformozilla*/
  253. @-moz-keyframesneon1{
  254. from{
  255. text-shadow:0010px#fff,
  256. 0020px#fff,
  257. 0030px#fff,
  258. 0040px#FF1177,
  259. 0070px#FF1177,
  260. 0080px#FF1177,
  261. 00100px#FF1177,
  262. 00150px#FF1177;
  263. }
  264. to{
  265. text-shadow:005px#fff,
  266. 0010px#fff,
  267. 0015px#fff,
  268. 0020px#FF1177,
  269. 0035px#FF1177,
  270. 0040px#FF1177,
  271. 0050px#FF1177,
  272. 0075px#FF1177;
  273. }
  274. }
  275. @-moz-keyframesneon2{
  276. from{
  277. text-shadow:0010px#fff,
  278. 0020px#fff,
  279. 0030px#fff,
  280. 0040px#228DFF,
  281. 0070px#228DFF,
  282. 0080px#228DFF,
  283. 00100px#228DFF,
  284. 00150px#228DFF;
  285. }
  286. to{
  287. text-shadow:005px#fff,
  288. 0010px#fff,
  289. 0015px#fff,
  290. 0020px#228DFF,
  291. 0035px#228DFF,
  292. 0040px#228DFF,
  293. 0050px#228DFF,
  294. 0075px#228DFF;
  295. }
  296. }
  297. @-moz-keyframesneon3{
  298. from{
  299. text-shadow:0010px#fff,
  300. 0020px#fff,
  301. 0030px#fff,
  302. 0040px#FFDD1B,
  303. 0070px#FFDD1B,
  304. 0080px#FFDD1B,
  305. 00100px#FFDD1B,
  306. 00150px#FFDD1B;
  307. }
  308. to{
  309. text-shadow:005px#fff,
  310. 0010px#fff,
  311. 0015px#fff,
  312. 0020px#FFDD1B,
  313. 0035px#FFDD1B,
  314. 0040px#FFDD1B,
  315. 0050px#FFDD1B,
  316. 0075px#FFDD1B;
  317. }
  318. }
  319. @-moz-keyframesneon4{
  320. from{
  321. text-shadow:0010px#fff,
  322. 0020px#fff,
  323. 0030px#fff,
  324. 0040px#B6FF00,
  325. 0070px#B6FF00,
  326. 0080px#B6FF00,
  327. 00100px#B6FF00,
  328. 00150px#B6FF00;
  329. }
  330. to{
  331. text-shadow:005px#fff,
  332. 0010px#fff,
  333. 0015px#fff,
  334. 0020px#B6FF00,
  335. 0035px#B6FF00,
  336. 0040px#B6FF00,
  337. 0050px#B6FF00,
  338. 0075px#B6FF00;
  339. }
  340. }
  341. @-moz-keyframesneon5{
  342. from{
  343. text-shadow:0010px#fff,
  344. 0020px#fff,
  345. 0030px#fff,
  346. 0040px#FF9900,
  347. 0070px#FF9900,
  348. 0080px#FF9900,
  349. 00100px#FF9900,
  350. 00150px#FF9900;
  351. }
  352. to{
  353. text-shadow:005px#fff,
  354. 0010px#fff,
  355. 0015px#fff,
  356. 0020px#FF9900,
  357. 0035px#FF9900,
  358. 0040px#FF9900,
  359. 0050px#FF9900,
  360. 0075px#FF9900;
  361. }
  362. }
  363. @-moz-keyframesneon6{
  364. from{
  365. text-shadow:0010px#fff,
  366. 0020px#fff,
  367. 0030px#fff,
  368. 0040px#ff00de,
  369. 0070px#ff00de,
  370. 0080px#ff00de,
  371. 00100px#ff00de,
  372. 00150px#ff00de;
  373. }
  374. to{
  375. text-shadow:005px#fff,
  376. 0010px#fff,
  377. 0015px#fff,
  378. 0020px#ff00de,
  379. 0035px#ff00de,
  380. 0040px#ff00de,
  381. 0050px#ff00de,
  382. 0075px#ff00de;
  383. }
  384. }
  385. /*glow*/
  386. @keyframesneon1{
  387. from{
  388. text-shadow:0010px#fff,
  389. 0020px#fff,
  390. 0030px#fff,
  391. 0040px#FF1177,
  392. 0070px#FF1177,
  393. 0080px#FF1177,
  394. 00100px#FF1177,
  395. 00150px#FF1177;
  396. }
  397. to{
  398. text-shadow:005px#fff,
  399. 0010px#fff,
  400. 0015px#fff,
  401. 0020px#FF1177,
  402. 0035px#FF1177,
  403. 0040px#FF1177,
  404. 0050px#FF1177,
  405. 0075px#FF1177;
  406. }
  407. }
  408. @keyframesneon2{
  409. from{
  410. text-shadow:0010px#fff,
  411. 0020px#fff,
  412. 0030px#fff,
  413. 0040px#228DFF,
  414. 0070px#228DFF,
  415. 0080px#228DFF,
  416. 00100px#228DFF,
  417. 00150px#228DFF;
  418. }
  419. to{
  420. text-shadow:005px#fff,
  421. 0010px#fff,
  422. 0015px#fff,
  423. 0020px#228DFF,
  424. 0035px#228DFF,
  425. 0040px#228DFF,
  426. 0050px#228DFF,
  427. 0075px#228DFF;
  428. }
  429. }
  430. @keyframesneon3{
  431. from{
  432. text-shadow:0010px#fff,
  433. 0020px#fff,
  434. 0030px#fff,
  435. 0040px#FFDD1B,
  436. 0070px#FFDD1B,
  437. 0080px#FFDD1B,
  438. 00100px#FFDD1B,
  439. 00150px#FFDD1B;
  440. }
  441. to{
  442. text-shadow:005px#fff,
  443. 0010px#fff,
  444. 0015px#fff,
  445. 0020px#FFDD1B,
  446. 0035px#FFDD1B,
  447. 0040px#FFDD1B,
  448. 0050px#FFDD1B,
  449. 0075px#FFDD1B;
  450. }
  451. }
  452. @keyframesneon4{
  453. from{
  454. text-shadow:0010px#fff,
  455. 0020px#fff,
  456. 0030px#fff,
  457. 0040px#B6FF00,
  458. 0070px#B6FF00,
  459. 0080px#B6FF00,
  460. 00100px#B6FF00,
  461. 00150px#B6FF00;
  462. }
  463. to{
  464. text-shadow:005px#fff,
  465. 0010px#fff,
  466. 0015px#fff,
  467. 0020px#B6FF00,
  468. 0035px#B6FF00,
  469. 0040px#B6FF00,
  470. 0050px#B6FF00,
  471. 0075px#B6FF00;
  472. }
  473. }
  474. @keyframesneon5{
  475. from{
  476. text-shadow:0010px#fff,
  477. 0020px#fff,
  478. 0030px#fff,
  479. 0040px#FF9900,
  480. 0070px#FF9900,
  481. 0080px#FF9900,
  482. 00100px#FF9900,
  483. 00150px#FF9900;
  484. }
  485. to{
  486. text-shadow:005px#fff,
  487. 0010px#fff,
  488. 0015px#fff,
  489. 0020px#FF9900,
  490. 0035px#FF9900,
  491. 0040px#FF9900,
  492. 0050px#FF9900,
  493. 0075px#FF9900;
  494. }
  495. }
  496. @keyframesneon6{
  497. from{
  498. text-shadow:0010px#fff,
  499. 0020px#fff,
  500. 0030px#fff,
  501. 0040px#ff00de,
  502. 0070px#ff00de,
  503. 0080px#ff00de,
  504. 00100px#ff00de,
  505. 00150px#ff00de;
  506. }
  507. to{
  508. text-shadow:005px#fff,
  509. 0010px#fff,
  510. 0015px#fff,
  511. 0020px#ff00de,
  512. 0035px#ff00de,
  513. 0040px#ff00de,
  514. 0050px#ff00de,
  515. 0075px#ff00de;
  516. }
  517. }
  518. /*REEEEEEEEEEESPONSIVE*/
  519. @media(max-width:650px){
  520. #container{
  521. width:100%;
  522. }
  523. p{
  524. font-size:3.5em;
  525. }
  526. }

以上就是本文的全部内容,希望对大家的学习有所帮助。

您可能有感兴趣的文章
css让页脚保持在底部位置的四种方案

CSS如何使用Flex和Grid布局如何实现3D骰子

Flex布局史上最简单使用语法教程

新的CSS 伪类函数 :is() 和 :where()示例详解

纯CSS打字动画的如何实现示例