gsap实现上传按钮动画效果
代码语言:html
所属分类:上传
代码描述:gsap实现上传按钮动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> @import url("https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700"); :root { --container-font-size: 28px; --container-background-color: #143982; --btn-upload-background-color: #0d5eff; --btn-upload-color: #ffffff; --btn-upload-width: 225px; --btn-upload-height: 80px; --btn-upload-border-radius: 0.75em; --btn-upload-transition-time: 50ms; --progress-width: 50px; --progress-height: 30px; --progress-top: -40px; --progress-arrow-color: #ffffff; --progress-arrow-background-color: #f53060; --progress-arrow-width: 8px; --progress-arrow-height: 8px; --check-width: 80px; --check-height: 45px; --check-stroke: 15px; } #container { font-family: "Open Sans", sans-serif; font-size: var(--container-font-size); background-color: var(--container-background-color); width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; overflow: hidden; } .btn-upload { color: var(--btn-upload-color); fill: var(--btn-upload-color); font-family: inherit; font-size: inherit; font-weight: bold; background-color: var(--btn-upload-background-color); width: var(--btn-upload-width); height: var(--btn-upload-height); padding: 0; border: 0; margin: 0; outline: 0; display: inline-flex; align-items: center; justify-content: center; position: relative; border-radius: var(--btn-upload-border-radius); box-shadow: 0 0.7em 1.2em rgba(25, 25, 25, 0.5); } .btn-upload:not(.btn-upload-uploading) { transition: box-shadow var(--btn-upload-transition-time) ease-out, transform var(--btn-upload-transition-time) ease-out; } .btn-upload:not(.btn-upload-uploading):hover { box-shadow: 0 0.7em 1.2em rgba(25, 25, 25, 0.8); } .btn-upload:not(.btn-upload-uploading):active { box-shadow: 0 0 0 rgba(25, 25, 25, 0.8); transform: translateY(0.2em); } .btn-upload > svg { fill: inherit; } .btn-upload > span { color: inherit; margin-left: 0.3em; } .progress { color: var(--progress-arrow-color); font-family: inherit; font-size: 50%; background-color: var(--progress-arrow-background-color); width: var(--progress-width); height: var(--progress-height); display: flex; align-items: center; justify-content: center; display: none; position: absolute; left: 0; top: var(--progress-top); border-radius: 0.5em; opacity: 0; transform-origin: center bottom; transform: translateX(-50%); filter: drop-shadow(0 0.7em 1.2em rgba(25, 25, 25, 0.5)); } .progress:after { content: ""; border-top: solid var(--progress-arrow-height) var(--progress-arrow-background-color); border-bottom: 0; border-left: solid calc(var(--progress-arrow-width) / 2) transparent; border-right: solid calc(var(--progress-arrow-width) / 2) transparent; position: absolute; top: calc(100% - 1px); } .check { width: var(--check-width); height: var(--check-height); display: none; position: absolute; top: calc(50% - calc(var(--check-width) / 2)); left: calc(50% - calc(var(--check-height) / 2)); transform-origin: center bottom; transform: rotate(-45deg); } .check > span { background-color: #ffffff; display: block; position: absolute; } .check > span:first-child { width: var(--check-stroke); height: 0; top: 0; left: 0; } .check > span:last-child { width: 0; height: var(--check-stroke); bottom: 0; left: 0; } </style> </head> <body translate="no"> <div id="container"> <button class="btn-upload" id="btn_upload"> <svg viewBox="0 0 640 512" width="32"> <path d="M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z"></path> </svg> <span>UPLOAD</span> <div class="progress"></div> <div class="check"> <span></span> <span></span> </div> </button> </div> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/gsap.3.3.1.js"></script> <script> "use strict"; const BTN_COLOR = "#ffffff"; const BTN_BACKGROUND_COLOR = "#0d5eff"; const BTN_WIDTH = 225; const BTN_HEIGHT = 80; const BTN_BORDER_RADIUS = "0.75em"; const BTN_SIZE = 180; const ANIMATION_TIME = 0.4; const UPLOADING_BACKGROUND_COLOR = "#ffffff"; const UPLOADING_WIDTH = 320; const UPLOADING_HEIGHT = 30; const DEFAULT_CONTAINER_BACKGROUND_COLOR = "#143982"; const DEFAULT_BTN_UPLOAD_BACKGROUND_COLOR = "#0d5eff"; const COMPLETE_CONTAINER_BACKGROUND_COLOR = "#005e02"; const COMPLETE_BTN_UPLOAD_BACKGROUND_COLOR = "#0fe600"; const COMPLETE_SIZE = 180; const CHECK_WIDTH = "100%"; const CHECK_HEIGHT = "100%"; const PROGRESS_TIME = 2; const container = document.........完整代码请登录后点击上方下载按钮下载查看
网友评论0