目錄
? Basic Glassmorphism Card
? Key CSS Properties Explained
? Tips for Better Results
首頁 web前端 css教學 CSS玻璃塑料效應示例

CSS玻璃塑料效應示例

Jul 29, 2025 am 04:21 AM
css

玻璃形態(Glassmorphism)的核心是通過半透明背景和背景模糊實現毛玻璃效果,關鍵步驟為:1. 使用rgba 設置元素半透明背景;2. 應用backdrop-filter: blur() 模糊背景內容;3. 添加淺色邊框和陰影增強層次感;4. 確保文本高對比度並在Safari 中添加-webkit-backdrop-filter 兼容支持,該效果在深色或動態背景下表現最佳。

css glassmorphism effect example

Glassmorphism is a popular UI design trend that creates a frosted glass effect, giving elements a translucent, layered look with blur and subtle borders. It's commonly used in modern dashboards, menus, and cards to create depth and visual interest.

css glassmorphism effect example

Here's a simple and effective CSS glassmorphism example you can use:


? Basic Glassmorphism Card

 <div class="glass-card">
  <h2>Welcome</h2>
  <p>This is a glassmorphism effect example using CSS.</p>
</div>
 body {
  background: url(&#39;https://source.unsplash.com/random/1920x1080/?nature&#39;) no-repeat center center fixed;
  background-size: cover;
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.glass-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); /* For Safari */
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
  padding: 30px;
  color: white;
  text-align: center;
  max-width: 300px;
}

? Key CSS Properties Explained

  • background: rgba(255, 255, 255, 0.1)
    Semi-transparent background to allow content behind to show through subtly.

    css glassmorphism effect example
  • backdrop-filter: blur(10px)
    Blurs everything behind the element (the key to the glass effect).

  • -webkit-backdrop-filter: blur(10px)
    Needed for Safari support.

    css glassmorphism effect example
  • border: 1px solid rgba(255, 255, 255, 0.3)
    Adds a light border to enhance the glassy look.

  • box-shadow
    Adds depth and a soft glow.


? Tips for Better Results

  • Use on dark or dynamic backgrounds (like images or gradients) to make the effect pop.
  • Avoid using on plain white backgrounds — the effect won't be visible.
  • Keep text high contrast (light text works best).
  • Test on Safari — always include -webkit-backdrop-filter .

This example gives you a clean, modern glass card that feels light and layered. You can apply the same styles to navbars, modals, or sidebars.

Basically just blur the background behind the element and use a semi-transparent fill — that's the core of glassmorphism.

以上是CSS玻璃塑料效應示例的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

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

熱門文章

Rimworld Odyssey如何釣魚
1 個月前 By Jack chen
Kimi K2:最強大的開源代理模型
1 個月前 By Jack chen
我可以有兩個支付帳戶嗎?
1 個月前 By 下次还敢

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Laravel 教程
1602
29
PHP教程
1506
276
如何使用CSS Backdrop-Filter屬性? 如何使用CSS Backdrop-Filter屬性? Aug 02, 2025 pm 12:11 PM

backdrop-filter用於對元素背後的內容應用視覺效果,1.使用backdrop-filter:blur(10px)等語法實現毛玻璃效果;2.支持blur、brightness、contrast等多種濾鏡函數並可疊加;3.常用於玻璃態卡片設計,需確保元素與背景重疊;4.現代瀏覽器支持良好,可用@supports提供降級方案;5.避免過大模糊值和頻繁重繪以優化性能,該屬性僅在元素背後有內容時生效。

如何在CSS中樣式鏈接? 如何在CSS中樣式鏈接? Jul 29, 2025 am 04:25 AM

鏈接的樣式應通過偽類區分不同狀態,1.使用a:link設置未訪問鏈接樣式,2.a:visited設置已訪問鏈接,3.a:hover設置懸停效果,4.a:active設置點擊時樣式,5.a:focus確保鍵盤可訪問性,始終遵循LVHA順序以避免樣式衝突,可通過添加padding、cursor:pointer和保留或自定義焦點輪廓來提升可用性和可訪問性,還可使用border-bottom或動畫下劃線等自定義視覺效果,最終確保鏈接在所有狀態下均有良好用戶體驗和可訪問性。

什麼是用戶代理樣式表? 什麼是用戶代理樣式表? Jul 31, 2025 am 10:35 AM

用戶代理樣式表是瀏覽器自動應用的默認CSS樣式,用於確保未添加自定義樣式的HTML元素仍具基本可讀性。它們影響頁面初始外觀,但不同瀏覽器存在差異,可能導致不一致顯示。開發者常通過重置或標準化樣式來解決這一問題。使用開發者工具的“計算”或“樣式”面板可查看默認樣式。常見覆蓋操作包括清除內外邊距、修改鏈接下劃線、調整標題大小及統一按鈕樣式。理解用戶代理樣式有助於提升跨瀏覽器一致性並實現精準佈局控制。

CSS方面比例屬性是什麼?如何使用它? CSS方面比例屬性是什麼?如何使用它? Aug 04, 2025 pm 04:38 PM

Theaspect-ratioCSSpropertydefinesthewidth-to-heightratioofanelement,ensuringconsistentproportionsinresponsivedesigns.1.Itisapplieddirectlytoelementslikeimages,videos,orcontainersusingsyntaxsuchasaspect-ratio:16/9.2.Commonusecasesincludemaintainingres

如何集中DIV CSS 如何集中DIV CSS Jul 30, 2025 am 05:34 AM

Tocenteradivhorizontally,setawidthandusemargin:0auto.2.Forhorizontalandverticalcentering,useFlexboxwithjustify-content:centerandalign-items:center.3.Alternatively,useCSSGridwithplace-items:center.4.Forolderbrowsers,useabsolutepositioningwithtop:50%,l

如何使用CSS創建彈跳動畫? 如何使用CSS創建彈跳動畫? Aug 02, 2025 am 05:44 AM

Define@keyframesbouncewith0%,100%attranslateY(0)and50%attranslateY(-20px)tocreateabasicbounce.2.Applytheanimationtoanelementusinganimation:bounce0.6sease-in-outinfiniteforsmooth,continuousmotion.3.Forrealism,use@keyframesrealistic-bouncewithscale(1.1

如何在CSS中重疊元素? 如何在CSS中重疊元素? Jul 30, 2025 am 05:43 AM

要實現CSS元素重疊,需使用定位和z-index屬性。 1.使用position和z-index:將元素設置為非static定位(如absolute、relative等),並通過z-index控制堆疊順序,值越大越靠前。 2.常見定位方法:absolute用於精確佈局,relative用於相對偏移並重疊相鄰元素,fixed或sticky用於固定定位的懸浮層。 3.實際示例:通過設置父容器position:relative,子元素position:absolute和不同z-index,可實現卡片重疊效果

如何使用CSS:空偽級? 如何使用CSS:空偽級? Aug 05, 2025 am 09:48 AM

:emptyPseudo-classSelectSelectsselemtswithnochildrenorcontent,包括pacesorcomments,sonlyTrulyEmpterementLikeMatchit; 1.ItcanhideEmptycontainersbousing:intume {note {note display:none;} toCleanuplayouts; 2.ItallowSaddingplacePlacePlacePlaceLanderStylingLingvia :: Forefore :: Forefor :: show offor :: show

See all articles