创建一个自定义border样式的调参效果

代码语言:html

所属分类:布局界面

代码描述:创建一个自定义border样式的调参效果

代码标签: border 样式 调参 效果

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

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
@import url("https://fonts.googleapis.com/css2?family=Open+Sans+Condensed:wght@300;700&display=swap");
*, *::before, *::after {
  padding: 0;
  margin: 0 auto;
  box-sizing: border-box;
}

body {
  font-family: 'Open Sans Condensed', sans-serif;
  min-height: 100vh;
  background-color: #eee;
  background-size: 10px 10px;
  background-image: radial-gradient(circle at 50% 50%, #ddd, #ddd 1px, transparent 1px), radial-gradient(circle at 0 0, #ddd, #ddd 1px, transparent 1px), radial-gradient(circle at 0 100%, #ddd, #ddd 1px, transparent 1px), radial-gradient(circle at 100% 0, #ddd, #ddd 1px, transparent 1px), radial-gradient(circle at 100% 100%, #ddd, #ddd 1px, transparent 1px);
  color: #333;
}

:root {
  --clr-border: #333;
  --AnimationLength: 0px;
}

.content {
  width: 100%;
  max-width: 960px;
  padding: 2em 2em 10em;
}

h2 {
  margin: 1em auto;
  text-decoration: underline;
  -webkit-text-decoration-color: #aaa;
          text-decoration-color: #aaa;
}
h2 span {
  color: #777;
}

p {
  margin: 2em auto;
  font-weight: bold;
}

hr {
  height: 3px;
  border: none;
  margin: 4em auto;
  background-color: #aaa;
}

.boxes {
  width: 100%;
  display: grid;
  grid-gap: 2em;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.box {
  display: -webkit-box;
  display: flex;
  -webkit-box-pack: center;
          justify-content: center;
  -webkit-box-align: center;
          align-items: center;
  width: 100%;
  height: 123px;
  font-size: 2em;
  padding: 0.5em;
  line-height: 1;
  background-position: 0 0, 0 0, 100% 0, 0 100%;
  background-size: 3px 100%, 100% 3px, 3px 100% , 100% 3px;
  background-repeat: no-repeat;
}

.box-a {
  background-image: repeating-linear-gradient(0deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px), repeating-linear-gradient(90deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px), repeating-linear-gradient(180deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px), repeating-linear-gradient(270deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px);
  -webkit-border-image: repeating-linear-gradient(0deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px);
       -o-border-image: repeating-linear-gradient(0deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px);
          border-image: repeating-linear-gradient(0deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px);
}

.box-b {
  background-image: repeating-linear-gradient(45deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px), repeating-linear-gradient(135deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px), repeating-linear-gradient(225deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px), repeating-linear-gradient(315deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px);
}

.box-c {
  background-image: repeating-linear-gradient(0deg, var(--clr-border), var(--clr-border) 3px, transparent 3px, transparent 6px), repeating-linear-gradient(90deg, var(--clr-border), var(--clr-border) 3px, transparent 3px, transparent 6px), repeating-linear-gradient(180deg, var(--clr-border), var(--clr-border) 3px, transparent 3px, transparent 6px), repeating-linear-gradient(270deg, var(--clr-border), var(--clr-border) 3px, transparent 3px, transparent 6px);
}

.box-d {
  background-image: repeating-linear-gradient(0deg, var(--clr-border), var(--clr-border) 30px, transparent 30px, transparent 36px), repeating-linear-gradient(90deg, var(--clr-border), var(--clr-border) 30px, transparent 30px, transparent 36px), repeating-linear-gradient(180deg, var(--clr-border), var(--clr-border) 30px, transparent 30px, transparent 36px), repeating-linear-gradient(270deg, var(--clr-border), var(--clr-border) 30px, transparent 30px, transparent 36px);
}

.box-e {
  background-image: -webkit-gradient(linear, left bottom, left top, from(var(--clr-border)), color-stop(25%, var(--clr-border)), color-stop(25%, transparent), color-stop(75%, transparent), color-stop(75%, var(--clr-border))), -webkit-gradient(linear, left top, right top, from(var(--clr-border)), color-stop(25%, var(--clr-border)), color-stop(25%, transparent), color-stop(75%, transparent), color-stop(75%, var(--clr-border))), -webkit-gradient(linear, left top, left bottom, from(var(--clr-border)), color-stop(25%, var(--clr-border)), color-stop(25%, transparent), color-stop(75%, transparent), color-stop(75%, var(--clr-border))), -webkit-gradient(linear, right top, left top, from(var(--clr-border)), color-stop(25%, var(--clr-border)), color-stop(25%, transparent), color-stop(75%, transparent), color-stop(75%, var(--clr-border)));
  background-image: linear-gradient(0deg, var(--clr-border), var(--clr-border) 25%, transparent 25%, transparent 75%, var(--clr-border) 75%), linear-gradient(90deg, var(--clr-border), var(--clr-border) 25%, transparent 25%, transparent 75%, var(--clr-border) 75%), linear-gradient(180deg, var(--clr-border), var(--clr-border) 25%, transparent 25%, transparent 75%, var(--clr-border) 75%), linear-gradient(270deg, var(--clr-border), var(--clr-border) 25%, transparent 25%, transparent 75%, var(--clr-border) 75%);
}

.box-f {
  background-image: -webkit-gradient(linear, left bottom, left top, color-stop(15%, transparent), color-stop(15%, var(--clr-border)), color-stop(85%, var(--clr-border)), color-stop(85%, transparent)), -webkit-gradient(linear, left top, right top, color-stop(15%, transparent), color-stop(15%, var(--clr-border)), color-stop(85%, var(--clr-border)), color-stop(85%, transparent)), -webkit-gradient(linear, left top, left bottom, color-stop(15%, transparent), color-stop(15%, var(--clr-border)), color-stop(85%, var(--clr-border)), color-stop(85%, transparent)), -webkit-gradient(linear, right top, left top, color-stop(15%, transparent), color-stop(15%, var(--clr-border)), color-stop(85%, var(--clr-border)), color-stop(85%, transparent));
  background-image: linear-gradient(0deg, transparent 15%, var(--clr-border) 15%, var(--clr-border) 85%, transparent 85%), linear-gradient(90deg, transparent 15%, var(--clr-border) 15%, var(--clr-border) 85%, transparent 85%), linear-gradient(180deg, transparent 15%, var(--clr-border) 15%, var(--clr-border) 85%, transparent 85%), linear-gradient(270deg, transparent 15%, var(--clr-border) 15%, var(--clr-border) 85%, transparent 85%);
}

.box-g {
  background-image: repeating-linear-gradient(0deg, var(--clr-border), var(--clr-border) 10px, transparent 20px, transparent 30px, var(--clr-border) 40px), repeating-linear-gradient(90deg, var(--clr-border), var(--clr-border) 10px, transparent 20px, transparent 30px, var(--clr-border) 40px), repeating-linear-gradient(180deg, var(--clr-border), var(--clr-border) 10px, transparent 20px, transparent 30px, var(--clr-border) 40px), repeating-linear-gradient(270deg, var(--clr-border), var(--clr-border) 10px, transparent 20px, transparent 30px, var(--clr-border) 40px);
}

.box-h {
  background-image: repeating-linear-gradient(0deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px), repeating-linear-gradient(90deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px), repeating-linear-gradient(180deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px), repeating-linear-gradient(270deg, var(--clr-border), var(--clr-border) 10px, transparent 10px, transparent 20px);
  background-size: 3px calc(100% + 20px), calc(100% + 20px) 3px, 3px calc(100% + 20px), calc(100% + 20px) 3px;
  -webkit-animation: boxBorderAnimation 1s infinite linear;
          animation: boxBorderAnimation 1s infinite linear;
}
@-webkit-keyframes boxBorderAnimation {
  from {
    background-position: 0 0, -20px 0, 100% -20px, 0 100%;
  }
  to {
    background-position: 0 -20px, 0 0, 100% 0, -20px 100%;
  }
}
@keyframes boxBorderAnimation {
  from {
    background-position: 0 0, -20px 0, 100% -20px, 0 100%;
  }
  to {
    background-position: 0 -20px, 0 0, 100% 0, -20px 100%;
  }
}
.generator {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-gap: 3em;
}
@.........完整代码请登录后点击上方下载按钮下载查看

网友评论0