当前位置: 首页 > news >正文

vue3 背景虚化,文字高亮效果

效果:

组件代码:

<template>
  <div :style="styleComputed" class="background-blurring">
    <div class="mask"></div>
    <div :style="styleComputed" class="blurring-text">background</div>
  </div>
</template>

<script setup>
import { computed } from "vue";
const props = defineProps({
  url: String
});

const styleComputed = computed(() => {
  return {
    backgroundImage: `url(${props.url})`
  };
});
</script>

<style scoped>
.background-blurring {
  background-repeat: no-repeat;
  width: 100%;
  height: 100%;
  font-size: 12vw;
  position: relative;
}
.background-blurring .blurring-text {
  width: 100%;
  height: 100%;
  -webkit-text-stroke: 2px #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  left: 0;
  top: 0;
  background-clip: text;
  color: #0000;
}
.mask {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
}
</style>

使用代码:

<template>
  // 传入图片资源
  <BackgroundBlurring :url="img"/>
<template>
  
<script setup>
// 引入组件
import BackgroundBlurring from "./components/BackgroundBlurring.vue";
// 引入资源
import img from "@/assets/imgs/background.jpg";
</script>

相关文章:

  • git输错用户名或者密码
  • 连续学习、增量学习有哪些应用场景?
  • JavaScript系列(77)-- Web Components 深入解析
  • vue3引用vue-ueditor-wrap组件
  • Log4j在Spring项目中的应用与实践
  • 钉钉多维表:数据管理与协作的新篇章
  • 数仓搭建(hive):DWB层(基础数据层)
  • 【核心算法篇九】《DeepSeek联邦学习:医疗数据隐私保护实战》
  • Spring IoC DI
  • 腿足机器人之十- SLAM地图如何用于运动控制
  • Compose 定制UI视图
  • Golang通过 并发计算平方 示例演示并发
  • 【Linux】Linux 文件系统——有关 inode 不足的案例
  • Golang实现简单的接口去重函数
  • Http升级为Https - 开发/测试服环境
  • MATLAB基础学习相关知识
  • 【Java】多线程和高并发编程(四):阻塞队列(上)基础概念、ArrayBlockingQueue
  • 深入理解IP地址与端口:网络通信的基石
  • 现代游戏UI架构深度解析——以UIController为核心的模块化界面管理系统
  • 华大MCU HC32F005端口GPIO控制失效问题
  • 旅游网站设计图片/新媒体运营工作是什么
  • 家居网站建设效果/怎么做网站模板
  • 做网站年赚千万/典型的网络营销案例
  • 微信官网网站/友情链接免费发布平台
  • 手机 上传 Wordpress/外链seo
  • 做网站如何处理并发问题/长春关键词优化公司