js+css实现可调节参数的渐变边框效果代码

代码语言:html

所属分类:布局界面

代码描述:js+css实现可调节参数的渐变边框效果代码,通过dat.gui实现参数可视化调节。

代码标签: js css 调节 参数 渐变 边框

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

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

<head>
  <meta charset="UTF-8">
  


  
  
<style>
*, *:after, *:before {
  box-sizing: border-box;
  transform-style: preserve-3d;
}

:root {
  --bg: hsl(0 0% 0%);
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: hsl(0 0% 14%);
}

article {
  color: hsl(0 0% 92%);
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    var(--gradient) border-box;
  border: calc(var(--border-width, 2) * 1px) solid transparent;
  padding: 2rem;
  border-radius: calc(var(--border-radius, 8) * 1px);
  width: 26ch;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 300;
  position: relative;
  transform: translate3d(0, 0, 0);
}
article:not(.faux) { z-index: 2; }

p {
  margin: 0;
}

/* Explosion */

[data-exploded] section {
  transition: transform 1s;
}

.faux {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: var(--gradient) border-box;
}

[data-exploded] section {
  transform: rotateX(60deg) rotate(25deg);
}

[data-imploding] article:not(.faux),
[data-exploded] article:not(.faux) {
  background: var(--bg) padding-box;
}

[data-exploded] article:not(.faux) p {
  transform: translate3d(0, 0, 200px);
}

[data-exploded] .faux {
  transform: translate3d(0, 0, -200px);
}
[data-exploded] .faux,
[data-exploded] article:not(.faux) p {
  transition: transform 1s 1.5s;
}

[data-exploded] label {
  opacity: 1;
  transition: 1s 1.5s;
}

label {
  transition: 1s 0s;
}

section {
  transition: transform 1s 1.5s;
}

article:not(.faux) p, .faux {
  transition: transform 1s 0s;
}

label {
  position: absolute;
  top: 50%;
  left: calc(100% + 2rem);
  white-space: nowrap;
  color: hsl(0 0% 70%);
  font-size: 1.5rem;
  translate: 0 -50%;
  opacity: 0;
  transform: translate3d(0, 0, calc(var(--z, 0) * 1px));
}

label:nth-of-type(1) {
  --z: 200;
}
label:nth-of-type(3) {
  --z: -200;
}
</style>


  
</head>

<body translate="no">
  <section>  
  <article class="faux"></article>
  <article class="card">
    <p>gradient borders using transparent borders...</p>
  </article>
  <label>Content</label>.........完整代码请登录后点击上方下载按钮下载查看

网友评论0