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;
相关推荐
a1117761 天前
汽车展厅项目 开源项目 ThreeJS
前端·开源·html
乆夨(jiuze)1 天前
记录一个css,实现下划线内容显示,支持文本多行显示
前端·css
ZC跨境爬虫1 天前
海南大学交友平台开发实战 day10(后端向前端输出_前端读取数据全流程联调+日志调试落地)
前端·python·sqlite·html·状态模式
xiaotao1311 天前
CSS中的Grid 布局
前端·css
Hilaku1 天前
做中后台业务,为什么我不建议你用 Tailwind CSS?
前端·css·代码规范
二进制person1 天前
JavaEE进阶 --HTML+CSS+JavaScript 基础
javascript·css·html
fīɡЙtīиɡ ℡1 天前
【SpringAi最新版入门(二)】
java·javascript·css·人工智能·css3
小李子呢02111 天前
前端八股CSS(3)---水平垂直居中的实现方法
前端·css·css3
观无1 天前
html+nginx实现看板
前端·nginx·html
聊聊MES那点事1 天前
报表控件Stimulsoft Reports.NET使用教程:发票报告设计
前端·javascript·html·报表工具