亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Vue實(shí)現(xiàn)液態(tài)玻璃登錄卡片的效果示例

 更新時(shí)間:2025年06月25日 11:33:51   作者:w_omit  
本文主要介紹了Vue實(shí)現(xiàn)液態(tài)玻璃登錄卡片,包括多層疊加、SVG濾鏡、3D傾斜交互等技術(shù),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

效果介紹

液態(tài)玻璃(Liquid Glass)是一種極具現(xiàn)代感的UI視覺風(fēng)格,常見于高端網(wǎng)站和操作系統(tǒng)界面。它通過(guò)多層疊加、模糊、光澤、濾鏡等技術(shù),模擬出玻璃的通透、折射和高光質(zhì)感。蘋果的這次系統(tǒng)設(shè)計(jì)更新,帶火了這一設(shè)計(jì)效果,本教程將帶你一步步實(shí)現(xiàn)一個(gè)帶有3D靈動(dòng)傾斜交互的液態(tài)玻璃登錄卡片。

實(shí)際效果:

Vue實(shí)現(xiàn)一個(gè)“液態(tài)玻璃”效果登錄卡片_3D

技術(shù)原理解析

1. 多層疊加

液態(tài)玻璃效果的核心是多層視覺疊加:

  • 模糊層(blur):讓背景內(nèi)容變得虛化,產(chǎn)生玻璃的通透感。
  • 色調(diào)層(tint):為玻璃加上一層淡淡的色彩,提升質(zhì)感。
  • 高光層(shine):模擬玻璃邊緣的高光和內(nèi)陰影,增強(qiáng)立體感。
  • SVG濾鏡:通過(guò) SVG 的 feTurbulencefeDisplacementMap,讓玻璃表面產(chǎn)生微妙的扭曲和流動(dòng)感。

2. 3D靈動(dòng)傾斜

通過(guò)監(jiān)聽鼠標(biāo)在卡片上的移動(dòng),動(dòng)態(tài)計(jì)算并設(shè)置 transform: perspective(...) rotateX(...) rotateY(...),讓卡片隨鼠標(biāo)靈動(dòng)傾斜,增強(qiáng)交互體驗(yàn)。

3. 背景與環(huán)境

背景可以是漸變色,也可以是圖片。玻璃卡片通過(guò) backdrop-filter 與背景內(nèi)容產(chǎn)生交互,形成真實(shí)的玻璃質(zhì)感。

實(shí)現(xiàn)步驟詳解

1. 結(jié)構(gòu)搭建

<template>
  <div class="login-container animated-background">
    <!-- SVG濾鏡庫(kù) -->
    <svg style="display: none">...</svg>
    <!-- 登錄卡片 -->
    <div
      class="glass-component login-card"
      ref="tiltCard"
      @mousemove="handleMouseMove"
      @mouseleave="handleMouseLeave"
    >
      <div class="glass-effect"></div>
      <div class="glass-tint"></div>
      <div class="glass-shine"></div>
      <div class="glass-content">
        <!-- 登錄表單內(nèi)容 -->
      </div>
    </div>
  </div>
</template>

2. SVG濾鏡實(shí)現(xiàn)液態(tài)扭曲

<svg style="display: none">
  <filter id="glass-distortion" x="0%" y="0%" width="100%" height="100%" filterUnits="objectBoundingBox">
    <feTurbulence type="fractalNoise" baseFrequency="0.001 0.005" numOctaves="1" seed="17" result="turbulence" />
    <feComponentTransfer in="turbulence" result="mapped">
      <feFuncR type="gamma" amplitude="1" exponent="10" offset="0.5" />
      <feFuncG type="gamma" amplitude="0" exponent="1" offset="0" />
      <feFuncB type="gamma" amplitude="0" exponent="1" offset="0.5" />
    </feComponentTransfer>
    <feGaussianBlur in="turbulence" stdDeviation="3" result="softMap" />
    <feSpecularLighting in="softMap" aceScale="5" specularConstant="1" specularExponent="100" lighting-color="white" result="specLight">
      <fePointLight x="-200" y="-200" z="300" />
    </feSpecularLighting>
    <feComposite in="specLight" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litImage" />
    <feDisplacementMap in="SourceGraphic" in2="softMap" scale="200" xChannelSelector="R" yChannelSelector="G" />
  </filter>
</svg>
  • 這段 SVG 代碼必須放在頁(yè)面結(jié)構(gòu)內(nèi),供 CSS filter 調(diào)用。

3. 背景設(shè)置

.animated-background {
  width: 100vw;
  height: 100vh;
  background-image: url('你的背景圖片路徑');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
}
  • 建議用高質(zhì)量漸變或壁紙,能更好襯托玻璃質(zhì)感。

4. 卡片多層玻璃結(jié)構(gòu)

.login-card {
  width: 400px;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 4px 24px 0 rgba(0,0,0,0.10), 0 1.5px 6px 0 rgba(0,0,0,0.08);
  background: transparent;
  position: relative;
}
.glass-effect {
  position: absolute;
  inset: 0;
  z-index: 0;
  backdrop-filter: blur(5px);
  filter: url(#glass-distortion);
  isolation: isolate;
  border-radius: 24px;
}
.glass-tint {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 24px;
}
.glass-shine {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 24px;
  box-shadow:
    inset 1px 1px 8px 0 rgba(255, 255, 255, 0.18),
    inset -1px -1px 8px 0 rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.glass-content {
  position: relative;
  z-index: 3;
  padding: 2rem;
  color: white;
}
  • 每一層都要有一致的 border-radius,才能保證圓角處無(wú)割裂。

5. 3D靈動(dòng)傾斜交互

methods: {
  handleMouseMove (e) {
    const card = this.$refs.tiltCard
    const rect = card.getBoundingClientRect()
    const x = e.clientX - rect.left
    const y = e.clientY - rect.top
    const centerX = rect.width / 2
    const centerY = rect.height / 2
    const maxTilt = 18
    const rotateY = ((x - centerX) / centerX) * maxTilt
    const rotateX = -((y - centerY) / centerY) * maxTilt
    card.style.transform = `perspective(600px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(1.03)`
  },
  handleMouseLeave () {
    const card = this.$refs.tiltCard
    card.style.transform = 'perspective(600px) rotateX(0deg) rotateY(0deg) scale(1)'
  }
}
  • 鼠標(biāo)移動(dòng)時(shí),卡片會(huì)根據(jù)指針位置靈動(dòng)傾斜。
  • 鼠標(biāo)移出時(shí),卡片平滑恢復(fù)。

6. 細(xì)節(jié)優(yōu)化

  • 陰影柔和:避免黑色邊緣過(guò)重,提升高級(jí)感。
  • 高光線條:用低透明度白色邊框和內(nèi)陰影,模擬玻璃高光。
  • 所有層的圓角一致:防止割裂。
  • 表單輸入框:用半透明背景和模糊,保持整體風(fēng)格統(tǒng)一。

7.完整代碼

<template>
  <div class="login-container animated-background">
    <!-- SVG濾鏡庫(kù) -->
    <svg style="display: none">
      <filter id="glass-distortion" x="0%" y="0%" width="100%" height="100%" filterUnits="objectBoundingBox">
        <feTurbulence type="fractalNoise" baseFrequency="0.001 0.005" numOctaves="1" seed="17" result="turbulence" />
        <feComponentTransfer in="turbulence" result="mapped">
          <feFuncR type="gamma" amplitude="1" exponent="10" offset="0.5" />
          <feFuncG type="gamma" amplitude="0" exponent="1" offset="0" />
          <feFuncB type="gamma" amplitude="0" exponent="1" offset="0.5" />
        </feComponentTransfer>
        <feGaussianBlur in="turbulence" stdDeviation="3" result="softMap" />
        <feSpecularLighting in="softMap" aceScale="5" specularConstant="1" specularExponent="100" lighting-color="white" result="specLight">
          <fePointLight x="-200" y="-200" z="300" />
        </feSpecularLighting>
        <feComposite in="specLight" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="litImage" />
        <feDisplacementMap in="SourceGraphic" in2="softMap" scale="200" xChannelSelector="R" yChannelSelector="G" />
      </filter>
    </svg>

    <!-- 登錄卡片 -->
    <div
      class="glass-component login-card"
      ref="tiltCard"
      @mousemove="handleMouseMove"
      @mouseleave="handleMouseLeave"
    >
      <div class="glass-effect"></div>
      <div class="glass-tint"></div>
      <div class="glass-shine"></div>
      <div class="glass-content">
        <h2 class="login-title">歡迎登錄</h2>
        <form class="login-form">
          <div class="form-group">
            <input type="text" placeholder="用戶名" class="glass-input">
          </div>
          <div class="form-group">
            <input type="password" placeholder="密碼" class="glass-input">
          </div>
          <button type="submit" class="glass-button">登錄</button>
        </form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LiquidGlass',
  data () {
    return {
      // 可以添加需要的數(shù)據(jù)
    }
  },
  methods: {
    handleMouseMove (e) {
      const card = this.$refs.tiltCard
      const rect = card.getBoundingClientRect()
      const x = e.clientX - rect.left
      const y = e.clientY - rect.top
      const centerX = rect.width / 2
      const centerY = rect.height / 2
      // 最大旋轉(zhuǎn)角度
      const maxTilt = 18
      const rotateY = ((x - centerX) / centerX) * maxTilt
      const rotateX = -((y - centerY) / centerY) * maxTilt
      card.style.transform = `perspective(600px) rotateX(${rotateX}deg) rotateY(${rotateY}deg) scale(1.03)`
    },
    handleMouseLeave () {
      const card = this.$refs.tiltCard
      card.style.transform = 'perspective(600px) rotateX(0deg) rotateY(0deg) scale(1)'
    }
  }
}
</script>

<style lang="scss" scoped>
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.animated-background {
  width: 100%;
  height: 100%;
  background-image: url('../../assets/macwallpaper.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.login-card {
  width: 400px;
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 4px 24px 0 rgba(0,0,0,0.10), 0 1.5px 6px 0 rgba(0,0,0,0.08);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.6);
  cursor: pointer;
  background: transparent;
}

.glass-effect {
  position: absolute;
  inset: 0;
  z-index: 0;
  backdrop-filter: blur(5px);
  filter: url(#glass-distortion);
  isolation: isolate;
  border-radius: 24px;
}

.glass-tint {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 24px;
}

.glass-shine {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 24px;
  box-shadow:
    inset 1px 1px 8px 0 rgba(255, 255, 255, 0.18),
    inset -1px -1px 8px 0 rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.glass-content {
  position: relative;
  z-index: 3;
  padding: 2rem;
  color: white;
}

.login-title {
  text-align: center;
  color: #fff;
  margin-bottom: 2rem;
  font-size: 2rem;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.form-group {
  margin-bottom: 1.5rem;
}

.glass-input {
  width: 90%;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1rem;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;

  &::placeholder {
    color: rgba(255, 255, 255, 0.7);
  }

  &:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
  }
}

.glass-button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
  position: relative;
  overflow: hidden;

  &:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
  }

  &:active {
    transform: translateY(0);
  }
}

// 添加點(diǎn)擊波紋效果
.click-gradient {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(180,180,255,0.2) 40%, rgba(100,100,255,0.1) 70%, rgba(50,50,255,0) 100%);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}

.glass-component.clicked .click-gradient {
  animation: gradient-ripple 0.6s ease-out;
}

@keyframes gradient-ripple {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0;
  }
}

.glass-component {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
</style>

常見問題與優(yōu)化建議

  • 陰影過(guò)重/黑邊:減小 box-shadow 的透明度和模糊半徑。
  • 圓角割裂:所有玻璃層都要加 border-radius。
  • 背景不通透:確保 glass-effect 層有 blur 和 SVG filter。
  • 性能問題:backdrop-filter 在低端設(shè)備上可能有性能損耗,建議只在必要區(qū)域使用。
  • 瀏覽器兼容性:backdrop-filter 需現(xiàn)代瀏覽器支持,IE/部分安卓瀏覽器不兼容。

技術(shù)要點(diǎn)總結(jié)

  • SVG濾鏡:讓玻璃表面有微妙的流動(dòng)和扭曲感。
  • backdrop-filter: blur:實(shí)現(xiàn)背景虛化。
  • 多層疊加:色調(diào)、高光、陰影共同營(yíng)造真實(shí)玻璃質(zhì)感。
  • 3D transform:提升交互體驗(yàn)。
  • 細(xì)節(jié)打磨:陰影、邊框、圓角、色彩都要精細(xì)調(diào)整。

結(jié)語(yǔ)

液態(tài)玻璃效果是現(xiàn)代前端視覺的代表之一。只要理解其原理,分層實(shí)現(xiàn)、細(xì)致調(diào)優(yōu),任何人都能做出媲美 macOS、Win11 的高端玻璃UI。希望本教程能幫助你掌握這項(xiàng)技術(shù),做出屬于自己的酷炫界面!

到此這篇關(guān)于Vue實(shí)現(xiàn)一個(gè)“液態(tài)玻璃”效果登錄卡片的文章就介紹到這了,更多相關(guān)Vue實(shí)現(xiàn)液態(tài)玻璃登錄卡片內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Vue組件封裝之input輸入框?qū)崙?zhàn)記錄

    Vue組件封裝之input輸入框?qū)崙?zhàn)記錄

    在vue中會(huì)將常用的組件進(jìn)行封裝,下面這篇文章主要給大家介紹了關(guān)于Vue組件封裝之input輸入框的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-10-10
  • 解決vue+element 鍵盤回車事件導(dǎo)致頁(yè)面刷新的問題

    解決vue+element 鍵盤回車事件導(dǎo)致頁(yè)面刷新的問題

    今天小編就為大家分享一篇解決vue+element 鍵盤回車事件導(dǎo)致頁(yè)面刷新的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • vue實(shí)現(xiàn)修改標(biāo)簽中的內(nèi)容:id class style

    vue實(shí)現(xiàn)修改標(biāo)簽中的內(nèi)容:id class style

    這篇文章主要介紹了vue實(shí)現(xiàn)修改標(biāo)簽中的內(nèi)容:id class style,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • vue實(shí)現(xiàn)web前端登錄頁(yè)數(shù)字驗(yàn)證碼

    vue實(shí)現(xiàn)web前端登錄頁(yè)數(shù)字驗(yàn)證碼

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)web前端登錄頁(yè)數(shù)字驗(yàn)證碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • vue3手動(dòng)刪除keepAlive緩存的方法

    vue3手動(dòng)刪除keepAlive緩存的方法

    當(dāng)我們未設(shè)置keepAlive的最大緩存數(shù)時(shí),當(dāng)緩存組件太多,會(huì)導(dǎo)致內(nèi)存溢出,本文給大家介紹了vue3手動(dòng)刪除keepAlive緩存的方法,文中通過(guò)代碼示例介紹的非常詳細(xì),需要的朋友可以參考下
    2024-03-03
  • vue獲取當(dāng)前點(diǎn)擊的元素并傳值的實(shí)例

    vue獲取當(dāng)前點(diǎn)擊的元素并傳值的實(shí)例

    下面小編就為大家分享一篇vue獲取當(dāng)前點(diǎn)擊的元素并傳值的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03
  • vue幾個(gè)常用跨域處理方式介紹

    vue幾個(gè)常用跨域處理方式介紹

    本篇文章給大家詳細(xì)介紹了vue跨域處理問題的方式以及相關(guān)知識(shí)點(diǎn)介紹,對(duì)此有興趣的朋友學(xué)習(xí)下。
    2018-02-02
  • Vue.js中對(duì)css的操作(修改)具體方式詳解

    Vue.js中對(duì)css的操作(修改)具體方式詳解

    使用v-bind:class或者v-bind:style或者直接通過(guò)操作dom來(lái)對(duì)其樣式進(jìn)行更改;接下來(lái)通過(guò)本文給大家分享Vue.js中對(duì)css的操作(修改)具體方式,感興趣的朋友跟隨小編一起看看吧
    2018-10-10
  • 使用Vue Router進(jìn)行路由組件傳參的實(shí)現(xiàn)方式

    使用Vue Router進(jìn)行路由組件傳參的實(shí)現(xiàn)方式

    Vue Router 為 Vue.js 應(yīng)用提供了完整的路由解決方案,其中包括了組件間的數(shù)據(jù)傳遞功能,通過(guò)路由組件傳參,我們可以輕松地在導(dǎo)航到新頁(yè)面時(shí)傳遞必要的數(shù)據(jù),本文將深入探討如何使用 Vue Router 進(jìn)行路由組件間的傳參,并通過(guò)多個(gè)示例來(lái)展示其實(shí)現(xiàn)方式
    2024-09-09
  • vue3+vite+SQL.js如何讀取db3文件數(shù)據(jù)

    vue3+vite+SQL.js如何讀取db3文件數(shù)據(jù)

    這篇文章主要介紹了vue3+vite+SQL.js如何讀取db3文件數(shù)據(jù)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05

最新評(píng)論