css 流动边框

一、背景流动边框

在这里插入图片描述
实现原理:
用背景进行旋转,超出我们想显示的范围则hidden,就有以上的效果,可以用after或者before元素来实现也可以。
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            position: relative;
            width: 150px;
            height: 150px;
            margin: 100px auto;
            overflow: hidden;
            border-radius: 4px;
        }
        @keyframes rotate {
            to {
                transform: rotate(1turn);
            }
        }
        .under {
            position: relative;
            width: 0px;
            height: 0px;
            border-top: 200px solid yellow;
            border-right: 200px solid green;
            border-bottom: 200px solid red;
            border-left: 200px solid blueviolet;
            left: -125px;
            top: -125px;
            animation: rotate 2s linear infinite;
        }
        .box > span {
            position: absolute;
            top: 0px;
            margin: 8px;
            width: 134px;
            height: 134px;
            border-radius: 4px;
            background-size: cover;
            background-image: url(https://img-blog.csdnimg.cn/20201011132854978.jpg);
            background-color: white;
        }
        @keyframes rotate2 {
            0%{
                transform: rotate(0turn);
            }
            to {
                transform: rotate(-1turn);
            }
        }
        .box .under2 {
            position: relative;
            width: 0px;
            height: 0px;
            border-top: 200px solid rgb(0, 255, 13);
            border-right: 200px solid rgb(45, 218, 203);
            border-bottom: 200px solid rgb(255, 106, 156);
            border-left: 200px solid rgb(251, 255, 26);
            left: -125px;
            top: -125px;
            animation: rotate2 2s linear infinite;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="under"></div>
        <span></span>
    </div>
    <div class="box">
        <div class="under2"></div>
        <span></span>
    </div>
</body>

</html>

二、跟随鼠标流动边框效果

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        :root {
            --bg: hsl(246 44% 7%);
            --border: hsl(280 10% 50% / 1);
            --card: hsl(237 36% 10%);
            --color: hsl(240 18% 80%);
            --border-width: 2px;
            --border-radius: 12px;
            --gradient: conic-gradient(from 180deg at 50% 70%, hsla(0, 0%, 98%, 1) 0deg, #eec32d 72.0000010728836deg, #ec4b4b 144.0000021457672deg, #709ab9 216.00000858306885deg, #4dffbf 288.0000042915344deg, hsla(0, 0%, 98%, 1) 1turn);
        }

        *,
        *:after,
        *:before {
            box-sizing: border-box;
        }

        @property --start {
            syntax: '<number>';
            inherits: true;
            initial-value: 0;
        }

        body {
            background: var(--bg);
            display: grid;
            place-items: center;
            min-height: 100vh;
            font-family: "Geist Sans", "SF Pro Text", "SF Pro Icons", "AOS Icons", "Helvetica Neue", Helvetica, Arial, sans-serif, system-ui;
            font-weight: 70;
            color: var(--color);
        }

        .container {
            --spread: 60;
            display: flex;
            flex-wrap: wrap;
            flex-direction: var(--direction);
            gap: calc(var(--gap) * 1px);
            margin: 0 auto;
            justify-content: center;
            place-items: center;
            position: relative;
            padding: 2rem;
            touch-action: none;
        }

        article {
            --active: 0.15;
            --start: 0;
            height: 100%;
            background: var(--card);
            padding: 4rem;
            aspect-ratio: 330 / 400;
            border-radius: var(--border-radius);
            min-width: 280px;
            max-width: 280px;
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
            position: relative;
        }

        article:is(:hover, :focus-visible) {
            z-index: 2;
        }

        .glows {
            pointer-events: none;
            position: absolute;
            inset: 0;
            filter: blur(calc(var(--blur) * 1px));
        }

        .glows::after,
        .glows::before {
            --alpha: 0;
            content: "";
            background: var(--gradient);
            background-attachment: fixed;
            position: absolute;
            inset: -5px;
            border: 10px solid transparent;
            border-radius: var(--border-radius);
            mask:
                linear-gradient(#0000, #0000),
                conic-gradient(from calc((var(--start) - (var(--spread) * 0.5)) * 1deg), #000 0deg, #fff, #0000 calc(var(--spread) * 1deg));
            mask-composite: intersect;
            mask-clip: padding-box, border-box;
            opacity: var(--active);
            transition: opacity 1s;
        }


        article::before {
            position: absolute;
            inset: 0;
            border: var(--border-width) solid transparent;
            content: "";
            border-radius: var(--border-radius);
            pointer-events: none;
            background: var(--border);
            background-attachment: fixed;
            border-radius: var(--border-radius);
            mask:
                linear-gradient(#0000, #0000),
                conic-gradient(from calc(((var(--start) + (var(--spread) * 0.25)) - (var(--spread) * 1.5)) * 1deg),
                    hsl(0 0% 100% / 0.15) 0deg,
                    white,
                    hsl(0 0% 100% / 0.15) calc(var(--spread) * 2.5deg));
            mask-clip: padding-box, border-box;
            mask-composite: intersect;
            opacity: var(--active);
            transition: opacity 1s;
        }

        article::after {
            --bg-size: 100%;
            content: "";
            pointer-events: none;
            position: absolute;
            background: var(--gradient);
            background-attachment: fixed;
            border-radius: var(--border-radius);
            opacity: var(--active, 0);
            transition: opacity 1s;
            --alpha: 0;
            inset: 0;
            border: var(--border-width) solid transparent;
            mask:
                linear-gradient(#0000, #0000),
                conic-gradient(from calc(((var(--start) + (var(--spread) * 0.25)) - (var(--spread) * 0.5)) * 1deg), #0000 0deg, #fff, #0000 calc(var(--spread) * 0.5deg));
            filter: brightness(1.5);
            mask-clip: padding-box, border-box;
            mask-composite: intersect;
        }

        .badge {
            border: 2px solid var(--border);
            align-self: start;
            border-radius: 100px;
            padding: 0.5rem 0.7rem;
            font-size: 0.675rem;
            display: flex;
            align-items: center;
            gap: 0.25rem;
            font-weight: 50;
        }

        a {
            color: var(--color);
            text-decoration: none;
            opacity: 0.5;
            display: inline-block;
            align-self: start;
            transition: opacity 0.2s;
        }

        a:is(:hover, :focus-visible) {
            opacity: 1;
        }

        article h2 {
            margin: 0;
            padding: 1rem 0;
            font-weight: 100;
            font-size: 1.5rem;
        }

        .header {
            position: relative;
            flex: 1;
            display: flex;
            align-items: center;
        }

        .header svg {
            --count: 4;
            width: 106px;
        }

        .header svg:nth-of-type(2),
        .header svg:nth-of-type(3),
        .header svg:nth-of-type(4) {
            position: absolute;
            z-index: calc(var(--count) - var(--index));
            translate: calc(var(--index) * 30%) 0;
            opacity: calc(var(--count) / (2 * (var(--index) * 10)));
        }

        .header svg:nth-of-type(2) {
            --index: 1;
        }

        .header svg:nth-of-type(3) {
            --index: 2;
        }

        .header svg:nth-of-type(4) {
            --index: 3;
        }

        .badge svg {
            width: 16px;
        }

        .dg.ac {
            z-index: 99999 !important;
        }
    </style>
</head>

<body>
    <div class="container" style="--gap:32;--blur:20;--spread:80;--direction:'column'">
        <article>
            <div class="glows"></div>

        </article>
        <article >
            <div class="glows" ></div>

        </article>
    </div>

    <script>
        const CONTAINER = document.querySelector('.container')
        const CARDS = document.querySelectorAll('article')

        const CONFIG = {
            proximity: 40,
            spread: 80,
            blur: 20,
            gap: 32,
            vertical: false,
            opacity: 0,
        }

        const PROXIMITY = 10

        const UPDATE = (event) => {
            // get the angle based on the center point of the card and pointer position
            for (const CARD of CARDS) {
                // Check the card against the proximity and then start updating
                const CARD_BOUNDS = CARD.getBoundingClientRect()
                // Get distance between pointer and outerbounds of card
                if (
                    event?.x > CARD_BOUNDS.left - CONFIG.proximity &&
                    event?.x < CARD_BOUNDS.left + CARD_BOUNDS.width + CONFIG.proximity &&
                    event?.y > CARD_BOUNDS.top - CONFIG.proximity &&
                    event?.y < CARD_BOUNDS.top + CARD_BOUNDS.height + CONFIG.proximity) {
                    // If within proximity set the active opacity
                    CARD.style.setProperty('--active', 1)
                } else {
                    CARD.style.setProperty('--active', CONFIG.opacity)
                }
                const CARD_CENTER = [
                    CARD_BOUNDS.left + CARD_BOUNDS.width * 0.5,
                    CARD_BOUNDS.top + CARD_BOUNDS.height * 0.5
                ]
                let ANGLE = Math.atan2(event?.y - CARD_CENTER[1], event?.x - CARD_CENTER[0]) * 180 / Math.PI
                ANGLE = ANGLE < 0 ? ANGLE + 360 : ANGLE;
                CARD.style.setProperty('--start', ANGLE + 90)
            }

        }

        document.body.addEventListener('pointermove', UPDATE)

        const RESTYLE = () => {
            CONTAINER.style.setProperty('--gap', CONFIG.gap)
            CONTAINER.style.setProperty('--blur', CONFIG.blur)
            CONTAINER.style.setProperty('--spread', CONFIG.spread)
            CONTAINER.style.setProperty('--direction', CONFIG.vertical ? 'column' : 'row')
        }



        RESTYLE()
        UPDATE()
    </script>
</body>

</html>

三、利用clip-path实现流动边框效果

四边:
在这里插入图片描述
两边:
请添加图片描述

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background-color: black;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .box {
            height: 150px;
            width: 150px;
            position: relative;
            border-radius: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            background-image: linear-gradient(45deg, gold, deeppink);
            /* animation: hue 3s infinite linear; */

            /* &::before,
            &::after {
                content: "";
                position: absolute;
                top: -15px;
                bottom: -15px;
                left: -15px;
                right: -15px;
                border: 5px solid #24acf2;
                border-image: linear-gradient(45deg, gold, deeppink) 1;
                clip-path: inset(0px round 10px);
                animation: clippath 3s infinite linear;
            }

            &::after {
                animation: clippath 3s infinite -1.5s linear;
            }

            span {
                color: white;
                font-size: 20px;
            } */
        }

        .line {
            position: absolute;
            top: -15px;
            bottom: -15px;
            left: -15px;
            right: -15px;
            border: 5px solid #24acf2;
            border-image: linear-gradient(45deg, gold, blue, deeppink) 1;
            /* clip-path: inset(0px round 10px); */
            animation: clippath 8s infinite linear;
            filter: blur(50px);
            animation-delay: -0s;
            box-shadow: 0 0 3px inset rgba(247, 214, 1,0.3);
        }

        .line-2 {
            animation-delay: -2s;
            animation: clippath2 8s infinite -2s linear;
            
        }

        .line-3 {
            animation-delay: -4s;
        }

        .line-4 {
            animation-delay: -6s;
            animation: clippath2 8s infinite -6s linear;

        }
        /* .line-2,.line-4{
            top: -20px;
            bottom: -20px;
            left: -20px;
            right: -20px;
        } */

        @keyframes hue {
            0% {
                filter: hue-rotate(0deg);
            }

            100% {
                filter: hue-rotate(360deg);
            }
        }

        @keyframes clippath {
            0% {
                clip-path: inset(0 0 95% 0);
                filter: hue-rotate(0deg) blur(5px);
            }

            25% {
                clip-path: inset(0 95% 0 0);
            }

            50% {
                clip-path: inset(95% 0 0 0);
            }

            75% {
                clip-path: inset(0 0 0 95%);
            }

            100% {
                clip-path: inset(0 0 95% 0);
                filter: hue-rotate(360deg) blur(5px);
            }
        }

        @keyframes clippath2 {
            0% {
                clip-path: inset(0 0 95% 0);
                filter: hue-rotate(0deg) blur(10px);
            }

            25% {
                clip-path: inset(0 95% 0 0);
            }

            50% {
                clip-path: inset(95% 0 0 0);
            }

            75% {
                clip-path: inset(0 0 0 95%);
            }

            100% {
                clip-path: inset(0 0 95% 0);
                filter: hue-rotate(360deg) blur(10px);
            }
        }
    </style>
</head>

<body>
    <div class="box">

        <div class="line-1 line"></div>
        <!-- <div class="line-2 line"></div> -->
        <div class="line-3 line"></div>
        <!-- <div class="line-4 line"></div> -->
        <span>hello world</span>
    </div>
</body>

</html>

四、
请添加图片描述

<button>
	<div>
		A beautiful button
	</div>
</button>

@property --border-angle-1 {
	syntax: "<angle>";
	inherits: true;
	initial-value: 0deg;
}

@property --border-angle-2 {
	syntax: "<angle>";
	inherits: true;
	initial-value: 90deg;
}

@property --border-angle-3 {
	syntax: "<angle>";
	inherits: true;
	initial-value: 180deg;
}


/* sRGB color. */
:root {
	--bright-blue: rgb(0, 100, 255);
	--bright-green: rgb(0, 255, 0);
	--bright-red: rgb(255, 0, 0);
	--background: black;
	--foreground: white;
	--border-size: 2px;
	--border-radius: 0.75em;
}

/* Display-P3 color, when supported. */
@supports (color: color(display-p3 1 1 1)) {
	:root {
		--bright-blue: color(display-p3 0 0.2 1);
		--bright-green: color(display-p3 0.4 1 0);
		--bright-red: color(display-p3 1 0 0);
	}
}

@keyframes rotateBackground {
	to { --border-angle-1: 360deg; }
}

@keyframes rotateBackground2 {
	to { --border-angle-2: -270deg; }
}

@keyframes rotateBackground3 {
	to { --border-angle-3: 540deg; }
}

body {
	background: var(--background);
	color: var(--foreground);
	min-height: 100dvh;
	display: grid;
	place-content: center;
	margin: 0;
	font-family: "Aspekta";
}

button {
	--border-angle-1: 0deg;
	--border-angle-2: 90deg;
	--border-angle-3: 180deg;
	color: inherit;
	font-size: calc(0.8rem + 4vmin);
	font-family: inherit;
	border: 0;
	padding: var(--border-size);
	display: flex;
	width: max-content;
	border-radius: var(--border-radius);
	background-color: transparent;
	background-image: conic-gradient(
			from var(--border-angle-1) at 10% 15%,
			transparent,
			var(--bright-blue) 10%,
			transparent 30%,
			transparent
		),
		conic-gradient(
			from var(--border-angle-2) at 70% 60%,
			transparent,
			var(--bright-green) 10%,
			transparent 60%,
			transparent
		),
		conic-gradient(
			from var(--border-angle-3) at 50% 20%,
			transparent,
			var(--bright-red) 10%,
			transparent 50%,
			transparent
		);
	animation: 
		rotateBackground 3s linear infinite,
		rotateBackground2 8s linear infinite,
		rotateBackground3 13s linear infinite;
}

/* Change this background to transparent to see how the gradient works */
button div {
	background: var(--background); 
	padding: 1em 1.5em;
	border-radius: calc(var(--border-radius) - var(--border-size));
	color: var(--foreground);
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/754887.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【开发环境】MacBook M2安装git并拉取gitlab项目,解决gitlab出现Access Token使用无效的方法

文章目录 安装Homebrew安装git打开IDEA配置git打开IDEA拉取项目 安装Homebrew /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"在iTerm等命令行工具打开后&#xff0c;输入上面的命令 之后根据中文提示完成Homebrew的下载…

web项目打包成可以离线跑的exe软件

目录 引言打开PyCharm安装依赖创建 Web 应用运行应用程序打包成可执行文件结语注意事项 引言 在开发桌面应用程序时&#xff0c;我们经常需要将网页集成到应用程序中。Python 提供了多种方法来实现这一目标&#xff0c;其中 pywebview 是一个轻量级的库&#xff0c;它允许我们…

PyScript:在浏览器中释放Python的强大

PyScript&#xff1a;Python代码&#xff0c;直接在网页上运行。- 精选真开源&#xff0c;释放新价值。 概览 PyScript是一个创新的框架&#xff0c;它打破了传统编程环境的界限&#xff0c;允许开发者直接在浏览器中使用Python语言来创建丰富的网络应用。结合了HTML界面、Pyo…

把飞书云文档变成HTML邮件:问题挑战与解决历程

一、背景 云文档转HTML邮件 基于公司内部的飞书办公套件&#xff0c;早在去年6月&#xff0c;我们就建设了将飞书云文档转译成HTML邮件的能力&#xff0c;方便同学们在编写邮件文档和发送邮件时&#xff0c;都能有较好的体验和较高的效率。 当下问题 要被邮件客户端识别&am…

【蓝桥杯省赛真题46】python数字币统计 中小学青少年组蓝桥杯比赛 算法思维python编程省赛真题解析

目录 python数字币统计 一、题目要求 1、编程实现 2、输入输出 二、算法分析 三、程序编写 四、程序说明 五、运行结果 六、考点分析 七、 推荐资料 1、蓝桥杯比赛 2、考级资料 3、其它资料 python数字币统计 第十四届蓝桥杯青少年组python比赛省赛真题 一、题目…

Spring Boot结合FFmpeg实现视频会议系统视频流处理与优化

在构建高效稳定的视频会议系统时,实时视频流的处理和优化是开发者面临的核心挑战之一。这不仅仅是简单的视频数据传输,更涉及到一系列复杂的技术问题,需要我们深入分析和有效解决。 高并发与实时性要求: 视频会议系统通常需要支持多人同时进行视频通话,这就意味着系统需要…

ONLYOFFICE8.1版本桌面编辑器——功能测评

一、编辑DOCX 相信大家都有写word文档的经历&#xff0c;不知道大家是不是跟我一样&#xff0c;感觉做一个word不难&#xff0c;但想做好一个word却很麻烦&#xff0c;功能太多&#xff0c;看的人眼花缭乱&#xff0c;有时候一个功能要找很久&#xff0c;甚至有的功能用一辈子都…

Matlab/simulink三段式距离/低阻抗保护

距离1段仿真波形如下所示 距离2段仿真波形如下所示 距离3段仿真波形如下所示

独立开发者系列(12)——下单与支付

做业务有个绕不开的业务逻辑&#xff0c;就是支付。这里总结一个基础的支付电商逻辑闭环流程&#xff0c;完成支付基础体系的实现。这里假定我们要实现的是一个独立的电商平台上允许用户在平台充值&#xff0c;其他的类似多多购物或者淘宝购物的流程逻辑。 数据表结构的逻辑设…

搭建Renesas R7FA8D1BHECBD-BTB的开发调试环境(DAP-LINK: N32G45XVL-STB)

目录 概述 1 软硬件 1.1 软硬件环境信息 1.2 开发板信息 1.3 调试器信息 2 FSP和KEIL产生测试项目 2.1 FSP生成项目 2.2 Keil中配置 3 硬件连接框图 4 一个测试案例 4.1 功能介绍 4.2 定时器函数 5 测试 搭建Renesas R7FA8D1BHECBD-BTB的开发调试环境&#xff08…

【漏洞复现】I doc view——任意文件读取

声明&#xff1a;本文档或演示材料仅供教育和教学目的使用&#xff0c;任何个人或组织使用本文档中的信息进行非法活动&#xff0c;均与本文档的作者或发布者无关。 文章目录 漏洞描述漏洞复现测试工具 漏洞描述 I doc view 在线文档预览是一个用于查看、编辑、管理文档的工具…

LabVIEW材料样本结构缺陷检测

本文介绍了一种基于LabVIEW的实验室振动特性分析测试装置&#xff0c;通过分析振动特性来检测结构缺陷。文章详细描述了具体案例、硬件型号、工作原理、软件功能以及注意事项。 硬件型号 振动传感器&#xff1a;PCB Piezotronics 352C33加速度计 数据采集卡&#xff1a;NI PXI…

天气网站爬虫及可视化

摘要&#xff1a;随着互联网的快速发展&#xff0c;人们对天气信息的需求也越来越高。本论文基于Python语言&#xff0c;设计并实现了一个天气网站爬虫及可视化系统。该系统通过网络爬虫技术从多个天气网站上获取实时的天气数据&#xff0c;并将数据进行清洗和存储。同时&#…

Windows下activemq集群配置(broker-network)

1.activemq版本信息 activemq&#xff1a;apache-activemq-5.18.4 2.activemq架构 3.activemq集群配置 activemq集群配置基于Networks of Brokers 这种HA方案的优点&#xff1a;是占用的节点数更少(只需要2个节点),而且2个broker都可以响应消息的接收与发送。不足&#xff…

下载旧版本vscode及扩展,离线下载远程linux服务器插件

背景 工作的内网没有网络&#xff0c;无法使用网络来下载插件和vscode软件&#xff0c;且有远程linux服务器需求&#xff0c;linux服务器中lib相关库比较旧且无法更新&#xff0c;所以需要选择一个旧版本的vscode&#xff0c;相应插件也需要选择旧版本的 旧版本vscode下载 没…

JavaWeb——MySQL:事务的简单学习

前面学习完了数据库增删查改的SQL语言&#xff0c;约束&#xff0c;数据库设计&#xff0c;以及多表查询&#xff0c;再学完事务就达到初级工程师的水平了。 6. 事务 6.1 概念 事务类似于编程语言的方法&#xff0c;包含一组SQL指令。 事务是不可分割的&#xff1b; 该指令步…

高中数学:复数-三角表示式

一、定义 辐角主值 二、复数乘除运算的三角表示及其几何意义 乘法 复数乘法的几何意义 除法 练习 解

机器学习 笔记

什么是机器学习 Machine Learning 约等于 Look for a function. 学习路线 监督学习&#xff1a; 回归Regression&#xff1a;指模型预估的输出是数值Classification&#xff1a;指模型预估的输出是类别&#xff0c;二分类的输出是或否会告诉机器正确的答案是什么 半监督学习…

xlsx插件简介

1. xlsx插件 1.1. 常用属性和方法 1.1.1. 创建新的工作簿1.1.2. 从数组生成工作表1.1.3. 添加工作表到工作簿1.1.4. 从HTML表格创建工作表1.1.5. 读取Excel文件1.1.6. 导出Excel文件1.1.7. 设置单元格样式 2. vue中如何使用xlsx 2.1. vue-xlsx的特点2.2. 常用属性和方法 2.2.1…

【操作与配置】WSL配置LINUX

WSL2&#xff08;Windows Subsystem for Linux 2&#xff09;是Microsoft开发的一项技术&#xff0c;允许用户在Windows操作系统上运行Linux发行版。WSL2是WSL&#xff08;Windows Subsystem for Linux&#xff09;的第二版&#xff0c;带来了许多改进和新特性。 官网&#xff…