CSS3 制作的彩虹按鈕樣式
發(fā)布時間:2021-04-09 17:32:50 作者:Giana
我要評論
這篇文章主要介紹了CSS3 制作的彩虹按鈕樣式,幫助大家更好的理解和學(xué)習(xí)使用CSS3制作特效,感興趣的朋友可以了解下
實現(xiàn)效果:

實現(xiàn)代碼:
html
<div class="buttons"> <h1>Simple hover effects with <code>box-shadow</code></h1> <button class="fill">Fill In</button> <button class="pulse">Pulse</button> <button class="close">Close</button> <button class="raise">Raise</button> <button class="up">Fill Up</button> <button class="slide">Slide</button> <button class="offset">Offset</button> </div>
CSS
/*
https://developer.mozilla.org/en/docs/Web/CSS/box-shadow
box-shadow: [inset?] [top] [left] [blur] [size] [color];
Tips:
- We're setting all the blurs to 0 since we want a solid fill.
- Add the inset keyword so the box-shadow is on the inside of the element
- Animating the inset shadow on hover looks like the element is filling in from whatever side you specify ([top] and [left] accept negative values to become [bottom] and [right])
- Multiple shadows can be stacked
- If you're animating multiple shadows, be sure to keep the same number of shadows so the animation is smooth. Otherwise, you'll get something choppy.
*/
.fill:hover,
.fill:focus {
box-shadow: inset 0 0 0 2em var(--hover);
}
.pulse:hover,
.pulse:focus {
-webkit-animation: pulse 1s;
animation: pulse 1s;
box-shadow: 0 0 0 2em rgba(255, 255, 255, 0);
}
@-webkit-keyframes pulse {
0% {
box-shadow: 0 0 0 0 var(--hover);
}
}
@keyframes pulse {
0% {
box-shadow: 0 0 0 0 var(--hover);
}
}
.close:hover,
.close:focus {
box-shadow: inset -3.5em 0 0 0 var(--hover), inset 3.5em 0 0 0 var(--hover);
}
.raise:hover,
.raise:focus {
box-shadow: 0 0.5em 0.5em -0.4em var(--hover);
transform: translateY(-0.25em);
}
.up:hover,
.up:focus {
box-shadow: inset 0 -3.25em 0 0 var(--hover);
}
.slide:hover,
.slide:focus {
box-shadow: inset 6.5em 0 0 0 var(--hover);
}
.offset {
box-shadow: 0.3em 0.3em 0 0 var(--color), inset 0.3em 0.3em 0 0 var(--color);
}
.offset:hover, .offset:focus {
box-shadow: 0 0 0 0 var(--hover), inset 6em 3.5em 0 0 var(--hover);
}
.fill {
--color: #a972cb;
--hover: #cb72aa;
}
.pulse {
--color: #ef6eae;
--hover: #ef8f6e;
}
.close {
--color: #ff7f82;
--hover: #ffdc7f;
}
.raise {
--color: #ffa260;
--hover: #e5ff60;
}
.up {
--color: #e4cb58;
--hover: #94e458;
}
.slide {
--color: #8fc866;
--hover: #66c887;
}
.offset {
--color: #19bc8b;
--hover: #1973bc;
}
button {
color: var(--color);
transition: 0.25s;
}
button:hover, button:focus {
border-color: var(--hover);
color: #fff;
}
body {
color: #fff;
background: #17181c;
font: 300 1em "Fira Sans", sans-serif;
justify-content: center;
align-content: center;
align-items: center;
text-align: center;
min-height: 100vh;
display: flex;
}
button {
background: none;
border: 2px solid;
font: inherit;
line-height: 1;
margin: 0.5em;
padding: 1em 2em;
}
h1 {
font-weight: 400;
}
code {
color: #e4cb58;
font: inherit;
}
以上就是CSS3 制作的彩虹按鈕樣式的詳細內(nèi)容,更多關(guān)于CSS3 按鈕樣式的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
這篇文章主要介紹了CSS3點擊按鈕圓形進度打鉤效果的實現(xiàn)代碼,代碼簡單易懂,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-03-30
基于css3文章列表喜歡點贊按鈕特效源碼簡單的js css3制作文章列表點擊按鈕喜歡或收藏功能。愛心點贊按鈕數(shù)量累計特效,非常不錯,喜歡的朋友快來下載吧2021-03-24
一套CSS3的新擬物風(fēng)格UI元素(復(fù)選框/按鈕/菜單/搜索框/時鐘)
這是基于CSS3和HTML5的新擬物風(fēng)格UI設(shè)計元素,包含單選/復(fù)選框、按鈕、Tab菜單、搜索框,另外還有時鐘等表單元素,歡迎下載2021-03-23
CSS3實現(xiàn)的登錄框表單浮動占位符和提交按鈕發(fā)光特效源碼
是一段基于CSS3實現(xiàn)的可用于各大網(wǎng)站登錄頁面的帶有浮動占位符和提交按鈕懸浮燈光加亮效果的登錄框代碼,非常實用又有趣,歡迎對此段代碼有興趣的朋友前來下載使用2021-03-22
今天給大家分享一個黑色系發(fā)光按鈕登錄表單,這個登錄表單最大的特點在于,它有一個帶炫酷動畫的登錄按鈕,非常不錯,喜歡的朋友快來下載體驗吧2021-02-19
這篇文章主要介紹了CSS3.0實現(xiàn)霓虹燈按鈕動畫特效的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來2021-01-12
css3制作單選框按鈕美化,方形的單選按鈕選中ui特效,非常不錯,喜歡的朋友快來下載吧2020-12-29
這篇文章主要介紹了CSS3中animation實現(xiàn)流光按鈕效果,本文通過實例代碼給大家介紹的非常詳細對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-12-21
CSS3分享圖標按鈕動畫特效代碼是一款社會分享圖標動畫特效,鼠標移上去會有一個膠囊閃動的效果。2020-12-15
CSS3鼠標懸停按鈕陰影縮放特效代碼是一款紅色簡潔的方形按鈕,鼠標懸停按鈕突出放大陰影效果,非常漂亮。2020-11-18










