随机字符背景效果
代码语言:html
所属分类:背景
代码描述:随机字符背景效果
代码标签: 效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> @font-face { font-family: 'Muli'; font-weight: 200 900; src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/240751/Muli-VariableFont_wght.ttf") format("truetype"); } @font-face { font-family: 'Playfair Display'; font-weight: 400 900; src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/240751/PlayfairDisplay-Italic-VariableFont_wght.ttf") format("truetype"); } *, *:before, *:after { box-sizing: border-box; } .sr, #app .toolbar input[type="checkbox"] { position: absolute; left: -100vw; width: 1px; height: 1px; opacity: 0; clip: rect(1px, 1px, 1px, 1px); } .float-right { float: right; margin-left: auto; } body { margin: 0; height: 100vh; width: 100vw; overflow: hidden; } #app { font-family: 'Muli'; color: #53565a; min-height: 100vh; } #app #grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); grid-auto-flow: dense; min-height: 100vh; -webkit-box-align: stretch; align-items: stretch; } #app .cell { width: 100%; line-height: 1em; display: -webkit-box; display: flex; -webkit-box-align: center; align-items: center; -webkit-box-pack: center; justify-content: center; font-size: calc(.7em + 3vmin); -webkit-transition: background 0.6s cubic-bezier(0.5, 0, 0.5, 1), font-weight 0.6s cubic-bezier(0.5, 0, 0.5, 1), color 0.6s cubic-bezier(0.5, 0, 0.5, 1); transition: background 0.6s cubic-bezier(0.5, 0, 0.5, 1), font-weight 0.6s cubic-bezier(0.5, 0, 0.5, 1), color 0.6s cubic-bezier(0.5, 0, 0.5, 1); font-weight: 200; width: 0; height: 0; padding: 50%; -webkit-animation: fadeOut 0.4s cubic-bezier(0.5, 0, 0.5, 1) forwards; animation: fadeOut 0.4s cubic-bezier(0.5, 0, 0.5, 1) forwards; } #app .cell:not(.fade) { -webkit-animation: fadeIn 0.4s cubic-bezier(0.5, 0, 0.5, 1) forwards; animation: fadeIn 0.4s cubic-bezier(0.5, 0, 0.5, 1) forwards; } #app .cell.m { grid-column: span 2; grid-row: span 2; font-size: calc(calc(.7em + 3vmin) * 2); } #app .cell.l { grid-column: span 3; grid-row: span 3; font-size: calc(calc(.7em + 3vmin) * 3); } #app .cell.xl { grid-column: span 4; grid-row: span 4; font-size: calc(calc(.7em + 3vmin) * 4); } #app .cell.xxl { grid-column: span 5; grid-row: span 5; font-size: calc(calc(.7em + 3vmin) * 4); } #app .cell.serif { font-family: 'Playfair Display', serif; } #app .cell.round { border-radius: 20em; padding: 46%; margin: 4%; } #app .cell[data-weight="900"] { font-weight: 900; } #app .cell[data-weight="200"] { font-weight: 200; background-color: #fff; } #app .cell:not(.colorized) { background-color: #fff !important; color: #53565a !important; } #app .toolbar { background: rgba(0, 0, 0, 0.85); -webkit-transition: left 0.3s cubic-bezier(0.5, 0, 0.5, 1); transition: left 0.3s cubic-bezier(0.5, 0, 0.5, 1); position: absolute; top: 0; padding: 1rem; height: 100vh; width: 100%; left: -100%; } @media (min-width: 420px) { #app .toolbar { max-width: 420px; left: -420px; } } #app .toolbar.shown { left: 0; overflow-y: scroll; } #app .toolbar.shown #hamburger { right: 0; background: transparent; top: 0; } #app .toolbar #hamburger { -webkit-transition: all 0.3 cubic-bezier(0.5, 0, 0.5, 1); transition: all 0.3 cubic-bezier(0.5, 0, 0.5, 1); width: 4rem; height: 4rem; background: inherit; position: absolute; right: -4rem; top: 1rem; border: none; border-top-right-radius: 2rem; border-bottom-right-radius: 2rem; font-size: 2rem; text-transform: uppercase; color: #fff; font-weight: 900; display: -webkit-box; display: flex; -webkit-box-align: center; align-items: center; -webkit-box-pack: center; justify-content: center; } #app .toolbar #hamburger:focus, #app .toolbar #hamburger:hover { color: #ffd100; outline: none; } #app .toolbar #shuffle, #app .toolbar .group { font-size: inherit; font-family: inherit; color: inherit; font-weight: 700; display: -webkit-box; display: flex; flex-wrap: wrap; -webkit-box-align: center; align-items: center; } #app .toolbar #shuffle { border: none; padding: 1rem; } #app .toolbar .group { width: 100%; color: #fff; margin: 0 0 1.5rem; font-size: 1.2rem; } #app .toolbar .group > * { -webkit-box-flex: 1; flex: 1 1 100%; margin-top: .5rem; } #app .toolbar label { display: -webkit-box; display: flex; -webkit-box-align: center; align-items: center; flex-wrap: wrap; position: relative; } #app .toolbar input[type="checkbox"] + label:before { content: ''; width: 1.2em; height: 1.2em; display: inline-block; border: 2px solid; margin-right: .5em; } #app .toolbar input[type="checkbox"]:checked + label:after { content: ''; width: .8rem; height: 1.2rem; -webkit-transform: rotate(45deg); transform: rotate(45deg); border-bottom: 0.3rem solid #ffd100; border-right: 0.3rem solid #ffd100; left: .3rem; bottom: .3rem; position: absolute; z-index: 2; } #app .toolbar input[type="checkbox"]:focus + label { color: #ffd100; } #app .toolbar button { -webkit-transition: background 0.2s cubic-bezier(0.5, 0, 0.5, 1); transition: background 0.2s cubic-bezier(0.5, 0, 0.5, 1); } #app .toolbar button:focus, #app .toolbar button:hover { outline: none; background-color: #ffd100; } #app .toolbar textarea { width: 100%; min-height: 3.5em; border: none; font-family: inherit; padding: .5em; font-size: inherit; background: transparent; border: 2px solid #fff; color: #fff; } @-webkit-keyframes fadeIn { from { opacity: 0; -webkit-transform: translateY(1em); transform: translateY(1em); } to { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); } } @keyframes fadeIn { from { opacity: 0; -webkit-transform: translateY(1em); transform: translateY(1em); } to { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); } } @-webkit-keyframes fadeOut { from { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); } to { opacity: 0; -webkit-transform: translateY(-1em); transform: translateY(-1em); } } @keyframes fadeOut { from { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); } to { opacity: 0; -webkit-transform: translateY(-1em); transform: translateY(-1em); } } </style> </head> <body translate="no"> <div id="app"> <div id="grid"> <div v-for="cell, index in grid" class="cell" :class="[colorize && 'colorized', getCellClasses(cell)]" :data-weight="cell.weight" :style="{backgroundColor: cell.color.bg, color: cell.color.fg}" @mouseover="hoverLetter" @click="randomLetter" :key="index" :data-serif="cell.serif"> {{ cell.blank > blankPercentage ? cell.char : '' }} </div> </div> <div class="toolbar" :class="isToolbarOpen && 'shown'"> <div :aria-hidden="!isToolbarOpen" :hidden="!isToolbarOpen"> <div class="group"> <label for="characters">Character set:</label> <textarea id="characters" @input="regenerateGrid" v-model="characters"></textarea> </div> <div class="group"> <label for="serifPercentage">Chances of serif cell: <span class="float-right">{{ serifPercentage }}%</span>&l.........完整代码请登录后点击上方下载按钮下载查看
网友评论0