css实现四种按钮悬停样式动画效果
代码语言:html
所属分类:悬停
代码描述:css实现四种按钮悬停样式动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="https://fonts.googleapis.com/css2?family=Orbitron&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Creepster&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Nixie+One&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Graduate&display=swap" rel="stylesheet"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> :root { --btn-width: 150px; --btn-height: 75px; --first-btn-squeeze: 0.9; --deep-blue: #101048; --orange: #f29e04; --swamp: #239702; --deep-purple: #6f0397; --inactive-blue: #1a647d; --active-blue: #3fc6f4; --red: #d20404; --light-orange: #fff1c5; --yellow: #ffef02; --hot-pink: #ff0563; --default: 0.5s; --fast: 0.3s; --fastest: 0.2s; } *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; text-decoration: none; user-select: none; } html { font-size: 10px; } html, body { display: block; position: relative; width: 100%; height: 100%; } body { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; } .button-container { display: flex; align-items: center; justify-content: center; height: 50%; width: 50%; min-height: 200px; overflow: hidden; } .button-container:first-of-type { background-color: var(--deep-blue); } .button-container:nth-of-type(2) { background-color: var(--orange); } .button-container:nth-of-type(3) { background-color: var(--swamp); } .button-container:nth-of-type(4) { background-color: var(--deep-purple); } @media screen and (max-width: 650px) { .button-container { width: 100%; } } .button { display: flex; justify-content: center; align-items: center; height: var(--btn-height); width: var(--btn-width); font-size: 1.6rem; color: black; cursor: pointer; } .button--glow { border-radius: 40px; font-size: 2rem; font-weight: bold; font-family: 'Nixie One', monospace; transition-property: box-shadow, background-color, transform; transition-duration: var(--default); background-color: var(--inactive-blue); box-shadow: none; } .button--glow:hover { background-color: var(--active-blue); box-shadow: 0px 0px 7px 7px white; } .button--glow:active { background-color: white; transform: scale(var(--first-btn-squeeze)); box-shadow: 0px 0px 30px 30px cyan; } .button--block { font-family: 'Graduate', sans-serif; transform: translate3d(-15px, -15px, 0); transition-property: box-shadow, transform; transition-duration: var(--fast); color: var(--red); border: 3px solid var(--red); background-color: var(--light-orange); box-shadow: 15px 15px 5px 0px black; } .button--block:active { transform: translate3d(-5px, -5px, 0); box-shadow: 5px 5px 0px 0px black; } .button--gooey { posit.........完整代码请登录后点击上方下载按钮下载查看
网友评论0