原生js实现文字翻牌动画显示效果

代码语言:html

所属分类:动画

代码描述:原生js实现文字翻牌动画显示效果

代码标签: 文字 翻牌 动画 显示 效果

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


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

<style>
@import url("https://fonts.googleapis.com/css?family=Fjalla+One&display=swap");
.numCounter {
  display: inline-block;
  height: 90px;
  line-height: 90px;
  text-shadow: 0 0 2px #fff;
  font-weight: bold;
  white-space: normal;
  font-size: 60px;
}
.numCounter > div {
  display: inline-block;
  vertical-align: top;
  height: 100%;
}
.numCounter > div > b {
  display: inline-block;
  width: 64.2857142857px;
  height: 100%;
  margin: 0 0.1em;
  border-radius: 8px;
  text-align: center;
  text-shadow: 2px 1px 3px rgba(0, 0, 0, 0.2);
  box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.1) inset, -2px -2px 2px rgba(255, 255, 255, 0.12) inset;
  overflow: hidden;
}
.numCounter > div > b::before {
  content: ' 0 1 2 3 4 5 6 7 8 9 ';
  display: block;
  word-break: break-all;
  word-break: break-word;
  -webkit-transition: 0.5s cubic-bezier(0.75, 0.15, 0.6, 1.15), text-shadow 150ms;
  transition: 0.5s cubic-bezier(0.75, 0.15, 0.6, 1.15), text-shadow 150ms;
}
.numCounter > div > b.blur {
  opacity: .8;
  text-shadow: 2px 1px 3px rgba(0, 0, 0, 0.2), 0 0.1em 2px rgba(255, 255, 255, 0.6), 0 0.3em 3px rgba(255, 255, 255, 0.3), 0 -0.1em 2px rgba(255, 255, 255, 0.6), 0 -0.3em 3px rgba(255, 255, 255, 0.3);
}
.numCounter > div > b[data-value="1"]::before {
  margin-top: -90px;
}
.numCounter > div > b[data-value="2"]::before {
  margin-top: -180px;
}
.numCounter > div > b[data-value="3"]::before {
  margin-top: -270px;
}
.numCounter > div > b[data-value="4"]::before {
  margin-top: -360px;
}
.numCounter > div > b[data-value="5"]::before {
  margin-top: -450px;
}
.numCounter > div > b[data-value="6"]::before {
  margin-top: -540px;
}
.numCounter > div > b[data-value="7"]::before {
  margin-top: -630px;
}
.numCounter > div > b[data-value="8"]::before {
  margin-top: -720px;
}
.numCounter > div > b[data-value="9"]::before {
  margin-top: -810px;
}
.numCounter > div:nth-last-child(3n):not(:first-child)::before {
  content: ",";
  display: inline;
  font-size: 1.1em;
  opacity: .6;
  color: white;
}

html, body {
  height: 100%;
}

body {
  display: -webkit-box;
  display: flex;
  -webkit-box-align: center;
          align-items: center;
  -webkit-box-pack: center;
          justify-content: center;
  background: #55b9f3;
  font-family: 'Fjalla One', Arial;
  -webkit-perspective: 1000px;
          perspective: 1000px;
}

aside {
  background: white;
  position: absolute;
  left: 0;
  top: 0;
  border-bottom-right-radius: 16px;
  overflow: hidden;
}

fieldset {
  text-transform: capitalize;
  font-weight: 700;
  font-size: .9em;
  border: 0;
  padding: 0;
  color: #0a5c8c;
}
fieldset label {
  padding: .8em;
  display: -webkit-box;
  display: flex;
  -webkit-box-align: center;
          align-items: center;
  height: 18px;
  border-top: 1px solid #55b9f3;
}
fieldset label:hover {
  background: #e4f4fd;
}
fieldset label > span {
  width: 180px;
  padding-right: 1em;
}

.numCounter {
  overflow: hidden;
  padding: .4em;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 0.5px solid rgba(255, 255, 255, 0.01);
  border-radius: 16px;
  background: linear-gradient(330deg, #6fc4f6, #3ea2dc);
  box-shadow: -20px -20px 60px #308fc6, 20px 20px 60px #7dcbf9;
}
.numCounter b {
  background: #40aae8;
  background: linear-gradient(-30deg, #62bff5, #2f99d7);
  color: white;
}
</style>

</head>
<body translate="no">
<aside>
<fieldset>
<label><span>number of digits</span>
<input type="range" min="1" max="12" value="7" name="numberOfDigits" />
</label>
<label><span title="De.........完整代码请登录后点击上方下载按钮下载查看

网友评论0