CSS实验:linear-gradient 实现「四角边框」和「 字体渐变」

background: linear-gradient(red, yellow, blue);

background: linear-gradient(red 0%, yellow 50%, blue 100%);

background: linear-gradient(to right, red 0%, yellow 50%, blue 100%);

background: linear-gradient(90deg, red 0%, yellow 50%, blue 100%);

to right代表渐变偏移角度,to right (相当于90deg)

1、四角边框的背景

这里我们使用linear-gradient方式实现,结合background一些其他属性,可以更加灵活。下面的方式是用linear-gradient画线的方式,画上下两条边,然后通过background-size的方式截取边角上的部分,组合形成的。

复制代码
width: 200px;
height: 200px;
padding: 10px;
background-origin: content-box;
background-color: #0e294c;
background-image: 
	linear-gradient(#4cc7f3 2px, transparent 2px, transparent calc(100% - 2px), #4cc7f3 calc(100% - 2px), #4cc7f3 100%),
	linear-gradient(90deg, #4cc7f3 2px, transparent 2px, transparent calc(100% - 2px), #4cc7f3 calc(100% - 2px), #4cc7f3 100%),
	linear-gradient(#4cc7f3 2px, transparent 2px, transparent calc(100% - 2px), #4cc7f3 calc(100% - 2px), #4cc7f3 100%),
	linear-gradient(90deg, #4cc7f3 2px, transparent 2px, transparent calc(100% - 2px), #4cc7f3 calc(100% - 2px), #4cc7f3 100%);
background-repeat: no-repeat;
background-position: top left, top left, bottom right, bottom right;
background-size: 10px 100%, 100% 10px;
相关推荐
石像鬼₧魂石1 小时前
【Y2Ksoft】四季贵州水世界乐园管理系统 —— 玻璃拟态 · 单文件HTML · 开箱即用
前端·html
叉歪1 小时前
为 UnoCSS 扩展无限色阶与主题换色
前端·css
梨想橙汁3 小时前
吃透HTML5:从基础标签到核心新特性全覆盖
html
石像鬼₧魂石5 小时前
【Y2Ksoft】贵阳陈桥饭店ERP管理系统
大数据·前端·物联网·html·数据库架构
TheITSea5 小时前
4、React+Tailwind CSS
前端·css·react.js
逝水无殇6 小时前
HTML 元素详解
开发语言·前端·html
iCOD3R21 小时前
Skill - kill-ai-slop 解决“AI 味”样式
前端·css·ai编程
阿酷tony1 天前
纯HTML5播放器带倍速、带画质切换的播放器
前端·html·html5
努力成为AK大王1 天前
CSS 入门完整笔记
前端·css
神明不懂浪漫2 天前
【第四章】CSS(二)——文本外观属性与复合选择器
前端·css·经验分享·笔记