搜尋
首頁web前端css教學如何使用 CSS 和 HTML 創建令人驚嘆的現代按鈕

探索採用發光漸層、動畫邊框和進階懸停效果精心打造的優質按鈕設計。非常適合需要高品質、引人注目的元素的網路專案。受到古羅馬角鬥士戰鬥的啟發,該按鈕設計捕捉了角鬥士之戰等遊戲所需的強度和風格。非常適合用於需要高端視覺體驗的互動遊戲、登陸頁面和使用者介面。

標籤:角鬥士之戰、進階按鈕、CSS 動畫、發光按鈕、互動設計、UI/UX、網頁設計、HTML/CSS、漸層動畫、古羅馬、遊戲介面、角鬥士遊戲


創建具有視覺吸引力的按鈕可以顯著增強網站的使用者體驗。本教學將引導您使用 HTML 和 CSS 建立高品質、現代的按鈕。我們將添加動畫、漸層和懸停效果,使其具有互動性和時尚性。跟著步驟創造一個讓人感覺優質且引人入勝的發光按鈕。

How to Create a Stunning Modern Button with CSS and HTML

第 1 步:設定 HTML 結構
我們的按鈕將被包裹在一個具有發光效果的容器中。 HTML 結構如下:



  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Premium Button Tutorial</title>
  <link rel="stylesheet" href="styles.css">



  <div>



<p>button-container: Holds the button and glow effect.<br>
premium-btn: The button itself, which includes an animation span for additional effects.<br>
outer-glow: Adds an animated glow around the button for a high-impact visual effect.<br>
Step 2: Setting Up CSS Styles<br>
Base Styles<br>
First, we’ll define the styles for the body and button container.<br>
</p>

<pre class="brush:php;toolbar:false">body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: #1b1b2f;
  margin: 0;
  font-family: Arial, sans-serif;
  overflow: hidden;
}

.button-container {
  position: relative;
  display: inline-block;
}

這些樣式使按鈕在螢幕上居中,並使用深色背景顏色來突出發光效果。

加入發光效果
外發光類別在按鈕周圍添加了大型的彩色發光。這種效果是透過漸層背景、模糊和脈動動畫來實現的。

.outer-glow {
  position: absolute;
  top: -25px;
  left: -25px;
  right: -25px;
  bottom: -25px;
  border-radius: 50px;
  background: linear-gradient(135deg, #1de9b6, #6a00f4, #ff4081, #1de9b6);
  background-size: 400% 400%;
  filter: blur(50px);
  opacity: 0.8;
  animation: pulseGlow 6s ease-in-out infinite;
  pointer-events: none;
}

按鈕樣式
接下來,讓我們設定按鈕本身的樣式。在這裡,我們添加漸層背景、粗體字體和陰影效果,以提升外觀。

.premium-btn {
  padding: 20px 50px;
  font-size: 22px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(45deg, #00c6ff, #0072ff);
  border: none;
  border-radius: 50px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.4s ease;
  text-transform: uppercase;
  letter-spacing: 2px;
  box-shadow: 0px 4px 20px rgba(0, 255, 255, 0.4);
  z-index: 1;
}

新增邊框動畫
按鈕內的 .border-animation 範圍可建立一個不斷旋轉的彩色邊框。

.border-animation {
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  border-radius: 50px;
  background: linear-gradient(90deg, #1de9b6, #6a00f4, #ff4081, #1de9b6);
  background-size: 300%;
  z-index: -1;
  animation: rotateBorder 4s ease-in-out infinite;
  filter: blur(8px);
}

懸停效果
為了使按鈕具有互動性,我們添加了懸停效果,以更改其背景漸層、增加框架陰影並觸發波紋效果。

.premium-btn:hover {
  background: linear-gradient(45deg, #ff4081, #1de9b6);
  color: #ffffff;
  box-shadow: 0px 6px 30px rgba(0, 255, 255, 0.6), 0px 6px 30px rgba(255, 64, 129, 0.6);
  transform: scale(1.05);
}

.premium-btn::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2), transparent 70%);
  transform: rotate(0deg);
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.9;
}

.premium-btn:hover::before {
  transform: rotate(45deg);
}

漣漪效應
當按鈕懸停在上方時,波紋效果會添加擴展的圓形動畫,給人一種時尚、現代的感覺。

.premium-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: width 0.4s ease, height 0.4s ease, opacity 0.5s ease;
}

.premium-btn:hover::after {
  width: 350%;
  height: 350%;
  opacity: 0;
}

關鍵影格的動畫
最後,我們定義發光邊框旋轉和脈動背景的關鍵影格。



  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Premium Button Tutorial</title>
  <link rel="stylesheet" href="styles.css">



  <div>



<p>button-container: Holds the button and glow effect.<br>
premium-btn: The button itself, which includes an animation span for additional effects.<br>
outer-glow: Adds an animated glow around the button for a high-impact visual effect.<br>
Step 2: Setting Up CSS Styles<br>
Base Styles<br>
First, we’ll define the styles for the body and button container.<br>
</p>

<pre class="brush:php;toolbar:false">body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: #1b1b2f;
  margin: 0;
  font-family: Arial, sans-serif;
  overflow: hidden;
}

.button-container {
  position: relative;
  display: inline-block;
}

使用 HTML 和 CSS 創建高級風格的按鈕是利用現代網頁設計技術來製作具有視覺吸引力和互動式元件的鼓舞人心的旅程。透過結合線性漸層、CSS 動畫和懸停效果,我們設計了一個充滿活力且引人入勝的按鈕,非常適合吸引用戶注意力並增強網站互動。

這個專案展示了 CSS 在創建分層效果方面的強大功能,例如發光輪廓、旋轉邊框和波紋動畫,所有這些都無需依賴 JavaScript。這不僅確保了快速、響應靈敏的介面,而且還強調了即使是微妙的設計選擇也可以顯著提升用戶體驗。

隨著我們不斷探索 CSS 和現代設計趨勢,進一步客製化有無限的可能性。本系列的後續文章將更深入探討創建互動式 Web 元件的藝術,探索用於響應式設計、複雜動畫和直覺 UX 模式的高級 CSS 技術。無論您是想增強個人專案還是專業網站,掌握這些樣式技術都將為您提供寶貴的工具,用於創建引人入勝、以使用者為中心的 Web 介面。

?發現更多:

探索角鬥士之戰:在 https://gladiatorsbattle.com 探索身臨其境的策略和戰鬥體驗
請參閱我們的 GitHub:查看程式碼範例和教學:https://github.com/HanGPIErr/Gladiators-Battle-Documentation
在 LinkedIn 上聯絡:在 LinkedIn 上關注我,以了解網頁設計和開發專案的最新動態,網址為 https://www.linkedin.com/in/pierre-romain-lopez/
追蹤 X:在 https://x.com/GladiatorsBT
上了解設計和遊戲專案的最新動態 透過繼續學習我們的課程,您將深入了解如何使用 HTML 和 CSS 創建美觀的響應式設計,以最少的程式碼突破 Web 互動性的界限。加入我們,探索更多技術,將引人入勝的優質元素帶入網路生活。

以上是如何使用 CSS 和 HTML 創建令人驚嘆的現代按鈕的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
CSS Flexbox與網格:全面評論CSS Flexbox與網格:全面評論May 12, 2025 am 12:01 AM

選擇Flexbox還是Grid取決於佈局需求:1)Flexbox適用於一維佈局,如導航欄;2)Grid適合二維佈局,如雜誌式佈局。兩者在項目中可結合使用,提升佈局效果。

如何包括CSS文件:方法和最佳實踐如何包括CSS文件:方法和最佳實踐May 11, 2025 am 12:02 AM

包含CSS文件的最佳方法是使用標籤在HTML的部分引入外部CSS文件。 1.使用標籤引入外部CSS文件,如。 2.對於小型調整,可以使用內聯CSS,但應謹慎使用。 3.大型項目可使用CSS預處理器如Sass或Less,通過@import導入其他CSS文件。 4.為了性能,應合併CSS文件並使用CDN,同時使用工具如CSSNano進行壓縮。

Flexbox vs Grid:我應該學習兩者嗎?Flexbox vs Grid:我應該學習兩者嗎?May 10, 2025 am 12:01 AM

是的,youshouldlearnbothflexboxandgrid.1)flexboxisidealforone-demensional,flexiblelayoutslikenavigationmenus.2)gridexcelstcelsintwo-dimensional,confffferDesignssignssuchasmagagazineLayouts.3)blosebothenHancesSunHanceSlineHancesLayOutflexibilitibilitibilitibilitibilityAnderibilitibilityAndresponScormentilial anderingStruction

軌道力學(或我如何優化CSS KeyFrames動畫)軌道力學(或我如何優化CSS KeyFrames動畫)May 09, 2025 am 09:57 AM

重構自己的代碼看起來是什麼樣的?約翰·瑞亞(John Rhea)挑選了他寫的一個舊的CSS動畫,並介紹了優化它的思維過程。

CSS動畫:很難創建它們嗎?CSS動畫:很難創建它們嗎?May 09, 2025 am 12:03 AM

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@KeyFrames CSS:最常用的技巧@KeyFrames CSS:最常用的技巧May 08, 2025 am 12:13 AM

@keyframesispopularduetoitsversatoryand and powerincreatingsmoothcsssanimations.keytricksinclude:1)definingsmoothtransitionsbetnestates,2)使用AnimatingMultatingMultationMultationProperPertiessimultane,3)使用使用4)使用BombingeNtibalibility,4)使用CombanningWiThjavoFofofofoftofofo

CSS計數器:自動編號的綜合指南CSS計數器:自動編號的綜合指南May 07, 2025 pm 03:45 PM

CSSCOUNTERSAREDOMANAGEAUTOMANAMBERINGINWEBDESIGNS.1)他們可以使用forterablesofcontents,ListItems,and customnumbering.2)AdvancedsincludenestednumberingSystems.3)挑戰挑戰InclassINCludeBrowsEccerCerceribaliblesibility andperformiballibility andperformissises.4)創造性

使用捲軸驅動動畫的現代滾動陰影使用捲軸驅動動畫的現代滾動陰影May 07, 2025 am 10:34 AM

使用滾動陰影,尤其是對於移動設備,是克里斯以前涵蓋的一個微妙的UX。傑夫(Geoff)涵蓋了一種使用動畫限制屬性的新方法。這是另一種方式。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

EditPlus 中文破解版

EditPlus 中文破解版

體積小,語法高亮,不支援程式碼提示功能