html动态边框,动态边框.html

* {

padding: 0;

margin: 0;

}

.container {

background: black;

position: relative;

border: 1px solid #ddd;

width: 450px;

height: 450px;

}

.sparkLine {

position: absolute;

transform-origin: left top;

}

.sparkLine .sparkParticle {

width: 1px;

height: 1px;

float: left;

color: white;

background: white;

box-shadow: 0 0 10px white;

opacity: 0;

}

@keyframes fade {

0% { opacity: 0; }

50% { opacity: 1; }

100% { opacity: 0; }

}

.sparkLine .sparkParticle {

}

function createLine(color, left, top, width, height, length, deg, size, speed) {

const sparkLine=document.createElement("div");

sparkLine.className="sparkLine";

sparkLine.style.top=`${top}px`;

sparkLine.style.left=`${left}px`;

sparkLine.style.width=`${length}px`;

sparkLine.style.height=`${height}px`;

sparkLine.style.transform=`rotateZ(${deg}deg)`;

for(let i = 0; i < size; i++){

const sparkParticle=document.createElement("div");

sparkParticle.className="sparkParticle";

sparkParticle.style.animation=`fade ${speed}s ${i/100}s infinite`;

sparkParticle.style.width=`${width}px`;

sparkParticle.style.height=`${height}px`;

sparkParticle.style.backgroundColor=color;

sparkLine.append(sparkParticle)

}

document.querySelector(".container").append(sparkLine);

}

//创建线

createLine('#102b6a', 20, 20, 2, 2, 418, 0 , 200, 1);//上

createLine('#102b6a', 418, 20, 2, 2, 418, 90, 200, 1);//右

createLine('#102b6a', 20, 418, 2, 2, 418, 0 , 200, 1);//下

createLine('#102b6a', 20, 20, 2, 2, 418, 90, 200, 1);//左

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值