checkbox表情悬浮动画选择效果
代码语言:html
所属分类:表单美化
代码描述:checkbox表情悬浮动画选择效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> @charset "UTF-8"; @font-face { font-family: "Quicksand"; font-weight: 500 700; src: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/240751/Quicksand-VariableFont_wght.ttf") format("truetype"); } *, *:before, *:after { box-sizing: border-box; } html { font-size: 1.125em; } body { margin: 0; min-height: 100vh; display: grid; grid-template-columns: 1fr; place-content: center; font-family: "Quicksand", sans-serif; font-display: swap; color: #53565a; background: #7ba7bc; } #app { width: 100%; max-width: calc(16rem + 6vmin); border-radius: 6px; margin: auto; border: 2px solid #53565a; padding: 2.5rem; background: #fff; box-shadow: 0.5em 0.5em 0 0 #34657f; } #app h1 { font-size: calc(1rem + 3vmin); margin: 0 0 0.75em; padding-bottom: 0.5em; line-height: 1em; border-bottom: 2px solid #a7a8aa; font-weight: normal; } #app h1 span { color: #ffd100; font-weight: bold; } #app form { font-size: calc(0.8rem + 2vmin); width: 100%; } #app form .group { line-height: 1; } #app form label { display: inline-block; line-height: 1.2; -webkit-transition: all 0.2s cubic-bezier(0.5, 0, 0.5, 1); transition: all 0.2s cubic-bezier(0.5, 0, 0.5, 1); border-bottom: 1px solid transparent; } #app form label:hover { cursor: url("http://repo.bfw.wiki/bfwrepo/icon/5e867b0cc54a2.png"), auto; } #app form input[type="checkbox"] { position: absolute; left: -100vw; width: 1px; height: 1px; opacity: 0; } #app form input[type="checkbox"]:disabled + label { color: #a7a8aa; } #app form input[type="checkbox"] + label { color: inherit; position: relative; padding: 0.15em 0.5em 0.15em 1.5em; overflow: hidden; } #app form input[type="checkbox"] + label:before { content: "⬜"; margin-right: 0.5em; display: inline-block; position: absolute; left: 0; -webkit-animation: uncheck 0.2s cubic-bezier(0.5, 0, 0.5, 1); animation: uncheck 0.2s cubic-bezier(0.5, 0, 0.5, 1); } #app form input[type="checkbox"] + label span:after { width: 0; height: 0.075em; border-radius: 0.075em; background: #e4002b; position: absolute; content: ""; left: 1.3em; top: 50%; -webkit-transition: width 0.2s cubic-bezier(0.5, 0, 0.5, 1); transition: width 0.2s cubic-bezier(0.5, 0, 0.5, 1); } #app form input[type="checkbox"]:checked + label { color: #ffd100; font-weight: bold; } #app form input[type="checkbox"]:checked + label:before { -webkit-animation: ✅ 0.2s cubic-bezier(0.5, 0, 0.5, 1) forwards; animation: ✅ 0.2s cubic-bezier(0.5, 0, 0.5, 1) forwards; } #app form input[type="checkbox"]:disabled + label { color: #a7a8aa; -webkit-transition-delay: 0.15s; transition-delay: 0.15s; } #app form input[type="checkbox"]:disabled + label span:after { width: calc(100% - 1.6em); -webkit-transition-delay: 0.15s; transition-delay: 0.15s; } #app form input[type="checkbox"]:disabled + label:hover, #app form input[type="checkbox"]:disabled + label *:hover { cursor: url("http://repo.bfw.wiki/bfwrepo/icon/5e867b534398e.png"), auto; } #app form input[type="checkbox"]#fast:disabled + label:before { -webkit-animation: 🐌 0.2s cubic-bezier(0.5, 0, 0.5, 1) both; animation: 🐌 0.2s cubic-bezier(0.5, 0, 0.5, 1) both; -webkit-animation-delay: 0.15s; animation-delay: 0.15s; } #app form input[type="checkbox"]#cheap:disabled + label:before { -webkit-animation: 💸 0.2s cubic-bezier(0.5, 0, 0.5, 1) both; animation: 💸 0.2s cubic-bezier(0.5, 0, 0.5, 1) both; -webkit-animation-delay: 0.15s; animation-delay: 0.15s; } #app form input[type="checkbox"]#good:disabled + label:before { -webkit-animation: 💩 0.2s cubic-bezier(0.5, 0, 0.5, 1) both; animation: 💩 0.2s cubic-bezier(0.5, 0, 0.5, 1) both; -webkit-animation-delay: 0.15s; animation-delay: 0.15s; } @-webkit-keyframes uncheck { 0% { -webkit-transform: scaleX(1) scaleY(1); transform: scaleX(1) scaleY(1); } 50% { -webkit-transform: scaleX(0.5) scaleY(0); transform: scaleX(0.5) scaleY(0); } 51% { content: "⬜"; } 100% { -webkit-transform: scaleX(1) scaleY(1); transform: scaleX(1) scaleY(1); content: "⬜"; } } @keyframes uncheck { 0% { -webkit-transform: scaleX(1) scaleY(1); transform: scaleX(1) scaleY(1); } 50% { -webkit-transform: scaleX(0.5) scaleY(0); transform: scaleX(0.5) scaleY(0); } 51% { content: "⬜"; } 100% { -webkit-transform: scaleX(1) scaleY(1); transform: scaleX(1) scaleY(1); content: "⬜"; } } @-webkit-keyframes ✅ { 0% { -webkit-transform: scaleX(1) scaleY(1); transform: scaleX(1) scaleY(1); content: "⬜"; } 5.........完整代码请登录后点击上方下载按钮下载查看
网友评论0