最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

效果介紹

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

實際效果:

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

技術原理解析

1. 多層疊加

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

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

2. 3D靈動傾斜

通過監(jiān)聽鼠標在卡片上的移動,動態(tài)計算并設置 transform: perspective(...) rotateX(...) rotateY(...),讓卡片隨鼠標靈動傾斜,增強交互體驗。

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

背景可以是漸變色,也可以是圖片。玻璃卡片通過 backdrop-filter 與背景內容產生交互,形成真實的玻璃質感。

實現(xiàn)步驟詳解

1. 結構搭建

<template>
  <div class="login-container animated-background">
    <!-- SVG濾鏡庫 -->
    <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">
        <!-- 登錄表單內容 -->
      </div>
    </div>
  </div>
</template>

2. SVG濾鏡實現(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 代碼必須放在頁面結構內,供 CSS filter 調用。

3. 背景設置

.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;
}
  • 建議用高質量漸變或壁紙,能更好襯托玻璃質感。

4. 卡片多層玻璃結構

.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,才能保證圓角處無割裂。

5. 3D靈動傾斜交互

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)'
  }
}
  • 鼠標移動時,卡片會根據指針位置靈動傾斜。
  • 鼠標移出時,卡片平滑恢復。

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

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

7.完整代碼

<template>
  <div class="login-container animated-background">
    <!-- SVG濾鏡庫 -->
    <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ù)據
    }
  },
  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)'
    }
  }
}
</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);
  }
}

// 添加點擊波紋效果
.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)化建議

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

技術要點總結

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

結語

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

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

相關文章

  • vue內置組件Transition的示例詳解

    vue內置組件Transition的示例詳解

    這篇文章主要介紹了vue內置組件Transition的詳解,簡單地說,就是當元素發(fā)生變化,比如消失、顯示時,添加動畫讓它更自然過渡,它是vue內置組件,不需要引入注冊就可以直接使用,本文通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-09-09
  • Vue中this.$nextTick()方法的使用及代碼示例

    Vue中this.$nextTick()方法的使用及代碼示例

    $nextTick()是Vue.js框架中的一個方法,它主要用于DOM操作,當我們修改Vue組件中的數(shù)據時,Vue.js會在下次事件循環(huán)前自動更新視圖,并異步執(zhí)行$nextTick()中的回調函數(shù),本文主要介紹了Vue中this.$nextTick()方法的使用及代碼示例,需要的朋友可以參考下
    2023-05-05
  • Vue頁面切換和a鏈接的本質區(qū)別詳解

    Vue頁面切換和a鏈接的本質區(qū)別詳解

    今天小編就為大家分享一篇Vue頁面切換和a鏈接的本質區(qū)別詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • Vue插件之滑動驗證碼

    Vue插件之滑動驗證碼

    這篇文章主要為大家詳細紹介紹了Vue插件之滑動驗證碼,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-09-09
  • vue單文件組件lint error自動fix與styleLint報錯自動fix詳解

    vue單文件組件lint error自動fix與styleLint報錯自動fix詳解

    這篇文章主要給大家介紹了關于vue單文件組件lint error自動fix與styleLint報錯自動fix的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-01-01
  • vite+vue3+pinia實現(xiàn)動態(tài)注冊懶加載路由教程

    vite+vue3+pinia實現(xiàn)動態(tài)注冊懶加載路由教程

    這篇文章主要介紹了vite+vue3+pinia實現(xiàn)動態(tài)注冊懶加載路由教程,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-04-04
  • vue報錯"vue-cli-service‘不是內部或外部命令,也不是...”的解決辦法

    vue報錯"vue-cli-service‘不是內部或外部命令,也不是...”的解決辦法

    這篇文章主要介紹了vue報錯"vue-cli-service‘不是內部或外部命令,也不是...”的解決辦法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-01-01
  • Vue2.0 事件的廣播與接收(觀察者模式)

    Vue2.0 事件的廣播與接收(觀察者模式)

    這篇文章主要介紹了Vue2.0 事件的廣播與接收(觀察者模式),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03
  • Vue封裝Swiper實現(xiàn)圖片輪播效果

    Vue封裝Swiper實現(xiàn)圖片輪播效果

    圖片輪播是前端中經常需要實現(xiàn)的一個功能。最近學習Vue.js,就針對Swiper進行封裝,實現(xiàn)一個簡單的圖片輪播組件。感興趣的朋友跟隨腳本之家小編一起學習吧
    2018-02-02
  • 使用vue制作探探滑動堆疊組件的實例代碼

    使用vue制作探探滑動堆疊組件的實例代碼

    探探的堆疊滑動組件起到了關鍵的作用,下面就來看看如何用vue寫一個探探的堆疊組件,感興趣的朋友一起看看吧
    2018-03-03

最新評論

东乡| 仪征市| 津市市| 丽水市| 新邵县| 西乌珠穆沁旗| 开阳县| 洛南县| 新巴尔虎右旗| 太原市| 沽源县| 湟源县| 苍溪县| 永丰县| 土默特右旗| 平舆县| 五大连池市| 张北县| 唐河县| 丰镇市| 墨江| 山东| 乐都县| 佛冈县| 蓝山县| 潢川县| 芜湖县| 北流市| 伊吾县| 仁化县| 延川县| 潍坊市| 仁化县| 江达县| 且末县| 南阳市| 会泽县| 杭锦旗| 玉环县| 南康市| 灌南县|