炫彩流光文字 html+css

您所在的位置:网站首页 炫彩字体p图软件 炫彩流光文字 html+css

炫彩流光文字 html+css

2023-07-19 22:40| 来源: 网络整理| 查看: 265

效果:

在这里插入图片描述

实现:

1. 定义标签,各自作用看后面解析:

live on.

2. 给底层盒子 main 与 .txt 定义基本样式:

main{ position: relative; overflow: hidden; } .txt{ color: rgb(255, 255, 255); text-transform: uppercase; font-size: 168px; background-color: rgb(0, 0, 0); user-select: none; }

overflow: hidden; 溢出自己大小范围子元素的隐藏;

color: rgb(255, 255, 255); 字体颜色设置为白色; text-transform: uppercase; 字母转换为大写; background-color: rgb(0, 0, 0); 背景色为黑色; user-select: none; 文本不可选中;

3. 给 .txt 定义一个双伪类元素

.txt::before{ content: "live on."; position: absolute; filter: blur(3px); mix-blend-mode: difference; }

filter: blur(3px); mix-blend-mode: difference; 差值模式。查看每个通道中的颜色信息,比较底色和绘图色,用较亮的像素点的像素值减去较暗的像素点的像素值。与白色混合将使底色反相;与黑色混合则不产生变化。 就是说写上这行后,便会看到字体只剩白色的边框,那是模糊出来的边框,字体原本的白色与它重叠父元素的白色都变为黑色了。可以自己试试。

4. 定义 .txt2 ,让它定位后覆盖在字体上。

.txt2{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(90deg,rgb(255, 0, 212),rgb(0, 119, 255),rgb(255, 187, 0),rgb(1, 255, 77)); mix-blend-mode: multiply ; }

background: linear-gradient(90deg,rgb(255, 0, 212),rgb(0, 119, 255),rgb(255, 187, 0),rgb(1, 255, 77)); 这是一个渐变的背景色。 mix-blend-mode: multiply ; 正片叠底,效果就是原本白色的字变成了有它渐变的颜色。

5. 定义 .txt3 ,大体就是为其设置一个有许多白色圆圈的背景,设置mix-blend-mode: color-dodge; 后, 当白色圆圈与字体重合时会有发亮的效果,再通过动画让这个背景从左上角偏移到右下角形成流光效果。

.txt3{ position: absolute; top:-100%; left:-100%; right:0; bottom:0; background-image: radial-gradient(circle,white ,black 30%); background-size: 25% 25%; mix-blend-mode: color-dodge; animation: shine 3s linear infinite; } @keyframes shine { 100% { transform: translate(50%,50%); } }

top:-100%; left:-100%; right:0; bottom:0; 背景大小。 background-image: radial-gradient(circle,white ,black 30%); 设置白黑色渐变的圆圈; background-size: 25% 25%; 圆的大小; mix-blend-mode: color-dodge; // 颜色减淡; transform: translate(50%,50%); 偏移;

完整代码: Document *{ font-family: 'Merienda', cursive; margin: 0; padding: 0; box-sizing: border-box; } body{ height: 100vh; background-color: rgb(0,0,0); display: flex; justify-content: center; align-items: center; } main{ position: relative; overflow: hidden; } .txt{ color: rgb(255, 255, 255); text-transform: uppercase; font-size: 168px; background-color: rgb(0, 0, 0); user-select: none; } .txt::before{ content: "live on."; position: absolute; /* text-shadow: 0 0 10px rgb(255, 255, 255), 0 0 10px rgb(255, 255, 255), 0 0 10px rgb(255, 255, 255); */ filter: blur(3px); mix-blend-mode: difference; } .txt2{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(90deg,rgb(255, 0, 212),rgb(0, 119, 255),rgb(255, 187, 0),rgb(1, 255, 77)); mix-blend-mode: multiply ; } .txt3{ position: absolute; top:-100%; left:-100%; right:0; bottom:0; background-image: radial-gradient(circle,white ,black 30%); background-size: 25% 25%; mix-blend-mode: color-dodge; animation: shine 3s linear infinite; } @keyframes shine { 100% { transform: translate(50%,50%); } } live on. 总结:

这篇的重点是 mix-blend-mode 混合模式属性。我感觉理解起来还是挺难和抽象的。

其它文章~: 气泡浮动背景特效 html+css 简约时钟特效 html+css+js 赛博朋克风格按钮 html+css 响应式卡片悬停效果 html+css 水波加载动画 html+css 导航栏滚动渐变效果 html+css+js 书本翻页 html+css 3D立体相册 html+css 炫彩流光按钮 html+css 三色边框旋转加载特效 html+css 记一些css属性总结(一) Sass总结笔记 …等等



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3