日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

html按钮线性炫光,6分钟实现CSS炫光倒影按钮 html+css

發布時間:2023/11/27 生活经验 71 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html按钮线性炫光,6分钟实现CSS炫光倒影按钮 html+css 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

話不多,先看效果:

回歸老本行,繼續分享簡單有趣的CSS創意特效,放松放松心情~

實現過程(完整源碼在最后):

1 老樣子,定義基本樣式:

*{

margin: 0;

padding: 0;

box-sizing: border-box;

font-family: 'fangsong';

}

body{

height: 100vh;

display: flex;

align-items: center;

justify-content: center;

background-color: rgb(0, 0, 0);

}

font-family: ‘fangsong’; 仿宋字體。

display: flex;

align-items: center;

justify-content: center; flex布局,讓按鈕在屏幕居中。

2.定義基本標簽:

aurora

aurora

aurora

3個a標簽就對應3個按鈕,每個按鈕里4個span就是環繞按鈕的4條邊。

且都有個公共的選擇器 .item 和 只屬于自己的選擇器。

3.定義每個按鈕的基本樣式:

.item{

position: relative;

margin: 50px;

width: 300px;

height: 80px;

text-align: center;

line-height: 80px;

text-transform: uppercase;

text-decoration: none;

font-size: 35px;

letter-spacing: 5px;

color: aqua;

overflow: hidden;

-webkit-box-reflect: below 1px linear-gradient( transparent,rgba(6, 133, 133,0.3));

}

text-align: center;文字對齊方式。

line-height: 80px; 字行高。

text-transform: uppercase; 字母為大寫。

text-decoration: none; 去掉a標簽默認下劃線。

letter-spacing: 5px; 每個字符間的距離。

overflow: hidden;溢出隱藏。

-webkit-box-reflect: below 1px linear-gradient( transparent,rgba(6, 133, 133,0.3)); 這個屬性能實現倒影效果。

4. 鼠標經過按鈕樣式改變:

.item:hover{

background-color: aqua;

box-shadow:0 0 5px aqua,

0 0 75px aqua,

0 0 155px aqua;

color: black;

}

box-shadow:0 0 5px aqua,

0 0 75px aqua,

0 0 155px aqua; 陰影,寫多行可以疊加更亮。

5.設置環繞按鈕的4根線上面那條的樣式:

.item span:nth-of-type(1){

position: absolute;

left: -100%;

width: 100%;

height: 3px;

background-image: linear-gradient(to left,aqua ,transparent);

animation: shang 1s linear infinite;

}

@keyframes shang{

0%{

left:-100%;

}

50%,100%{

left:100%;

}

}

position: absolute;

left: -100%; 定位在對應位置。

background-image: linear-gradient(to left,aqua ,transparent); 線性漸變顏色。

animation: shang 1s linear infinite; 動畫屬性,讓它動起來。

5.以此類推,設置環繞按鈕的其它3根樣式:

.item span:nth-of-type(2){

position: absolute;

top: -100%;

right: 0;

width: 3px;

height: 100%;

background-image: linear-gradient(to top,aqua ,transparent);

animation: you 1s linear infinite;

animation-delay: 0.25s;

}

@keyframes you{

0%{

top:-100%;

}

50%,100%{

top:100%;

}

}

.item span:nth-of-type(3){

position: absolute;

right: -100%;

bottom: 0;

width: 100%;

height: 3px;

background-image: linear-gradient(to right,aqua ,transparent);

animation: xia 1s linear infinite;

animation-delay: 0.5s;

}

@keyframes xia{

0%{

right:-100%;

}

50%,100%{

right:100%;

}

}

.item span:nth-of-type(4){

position: absolute;

bottom: -100%;

left: 0;

width: 3px;

height: 100%;

background-image: linear-gradient(to bottom,aqua ,transparent);

animation: zuo 1s linear infinite;

animation-delay: 0.75s;

}

@keyframes zuo{

0%{

bottom:-100%;

}

50%,100%{

bottom:100%;

}

}

animation-delay: 0.75s; 動畫延遲執行。每條線對應延遲一段時間,形成時間差,形成環繞效果。

6.給第一,第三個按鈕設置其它顏色:

.item1{

filter: hue-rotate(100deg);

}

.item3{

filter: hue-rotate(250deg);

}

filter: hue-rotate(100deg); 用色相旋轉,這樣不管背景還是陰影顏色都變了。

完整代碼:

Document

margin: 0;

padding: 0;

box-sizing: border-box;

font-family: 'fangsong';

}

body{

height: 100vh;

display: flex;

align-items: center;

justify-content: center;

background-color: rgb(0, 0, 0);

}

.item{

position: relative;

margin: 50px;

width: 300px;

height: 80px;

text-align: center;

line-height: 80px;

text-transform: uppercase;

text-decoration: none;

font-size: 35px;

letter-spacing: 5px;

color: aqua;

overflow: hidden;

-webkit-box-reflect: below 1px linear-gradient( transparent,rgba(6, 133, 133,0.3));

}

.item:hover{

background-color: aqua;

box-shadow:0 0 5px aqua,

0 0 75px aqua,

0 0 155px aqua;

color: black;

}

.item span:nth-of-type(1){

position: absolute;

left: -100%;

width: 100%;

height: 3px;

background-image: linear-gradient(to left,aqua ,transparent);

animation: shang 1s linear infinite;

}

@keyframes shang{

0%{

left:-100%;

}

50%,100%{

left:100%;

}

}

.item span:nth-of-type(2){

position: absolute;

top: -100%;

right: 0;

width: 3px;

height: 100%;

background-image: linear-gradient(to top,aqua ,transparent);

animation: you 1s linear infinite;

animation-delay: 0.25s;

}

@keyframes you{

0%{

top:-100%;

}

50%,100%{

top:100%;

}

}

.item span:nth-of-type(3){

position: absolute;

right: -100%;

bottom: 0;

width: 100%;

height: 3px;

background-image: linear-gradient(to right,aqua ,transparent);

animation: xia 1s linear infinite;

animation-delay: 0.5s;

}

@keyframes xia{

0%{

right:-100%;

}

50%,100%{

right:100%;

}

}

.item span:nth-of-type(4){

position: absolute;

bottom: -100%;

left: 0;

width: 3px;

height: 100%;

background-image: linear-gradient(to bottom,aqua ,transparent);

animation: zuo 1s linear infinite;

animation-delay: 0.75s;

}

@keyframes zuo{

0%{

bottom:-100%;

}

50%,100%{

bottom:100%;

}

}

.item1{

filter: hue-rotate(100deg);

}

.item3{

filter: hue-rotate(250deg);

}

aurora

aurora

aurora

總結:

總結

以上是生活随笔為你收集整理的html按钮线性炫光,6分钟实现CSS炫光倒影按钮 html+css的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。