原生js+css实现卡通风格待办事项应用代码
代码语言:html
所属分类:其他
代码描述:原生js+css实现卡通风格待办事项应用代码
代码标签: 原生 js css 卡通 风格 待办 事项 应用 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> @import url('https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap'); * { margin: 0; padding: 0; box-sizing: border-box; } body { --add-todo-active: 0; min-height: 100vh; background-color: #222; display: grid; font-family: Poppins, sans-serif; } :root { --hue: 20; --accent: hsl(var(--hue), 80%, 50%); --dark-accent: hsl(var(--hue), 100%, 5%); --light-accent: hsl(var(--hue), 100%, 95%); } .add-todo { --active: 0; position: absolute; top: 0; left: 50%; translate: -50% 0; width: max(250px, calc(80vmin * var(--active))); height: max(50px, calc(150px * var(--active))); display: block; border: none; background-color: transparent; overflow: visible; transition: top .5s, width .5s, height .5s, translate .5s; z-index: 10; } .add-todo::before, .add-todo::after { content: ''; position: absolute; height: 50px; aspect-ratio: 1; background-color: var(--accent); left: -50px; top: 0; z-index: 0; mask: radial-gradient(circle 25px, #0000 24px, #000 25px), linear-gradient(45deg, #000 52px, #0000 50px); mask-composite: subtract; clip-path: inset(0 0 0 25px); } .add-todo::after { left: 100%; mask: radial-gradient(circle 25px, #0000 24px, #000 25px), linear-gradient(-45deg, #000 52px, #0000 50px); mask-composite: subtract; clip-path: inset(0 25px 0 0); } .add-todo .inner { position: relative; width: 100%; height: 100%; background-color: var(--accent); padding: 1rem 2rem; border-radius: 0 0 25px 25px; display: grid; grid-template-columns: 1fr; grid-template-rows: 50px 1fr; overflow: hidden; transition: border-radius .5s; border-bottom: 3px solid black; } .add-todo header { display: flex; align-items: center; justify-content: center; } .add-todo header h1 { color: var(--light-accent); font-weight: 300; display: flex; align-items: center; justify-content: center; } .add-todo header h1 svg { width: 50px; aspect-ratio: 1; opacity: 1; } .add-todo .todo-input-section { display: flex; } .add-todo .todo-input-section .todo-input-wrapper { display: flex; width: 100%; align-items: center; } .add-todo .todo-input-section .todo-input-wrapper .todo-input { width: 100%; background-color: transparent; border: none; font-family: Poppins, sans-serif; color: var(--dark-accent); font-size: 1.3rem; } .add-todo .todo-input-section .todo-input:is(:active, :focus-within) { outline: none; } .add-todo .todo-input-section .todo-input::placeholder { color: rgba(255 255 255 / .3); } .add-todo .todo-input-section .todo-input-wrapper .add-todo-btn { width: 50px; height: 50px; background-color: transparent; border: none; cursor: pointer; color: var(--dark-accent); transition: opacity .3s, scale .1s; } .add-todo-btn:active { opacity: .7; scale: 1.1; } .add-todo-btn svg { width: 100%; height: 100%; } .add-todo:popover-open, body:has(.add-todo:popover-open) { --active: 1; --add-todo-active: 1; } .add-todo [popovertarget] { position: absolute; width: calc(100% * (1 - var(--active))); height: calc(100% * (1 - var(--active))); top: 50%; left: 50%; translate: -50% -50%; background-color: var(--accent); background-clip: padding-box; opacity: calc(1 - var(--active)); border: 3px solid transparent; border-radius: 25px; overflow: hidden; font-family: Poppins, sans-serif; font-size: 1.2rem; font-weight: 700; letter-spacing: -1px; word-spacing: 2px; color: var(--dark-accent); cursor: pointer; transition: width .5s, height .5s, translate .5s, opacity .5s; } [popover]:popover-open::backdrop { background-color: rgba(0 0 0 / .6); } [popover]::backdrop { background-color: transparent; transition: background-color .3s allow-discrete; } @starting-style { [popover]:popover-open::backdrop { background-color: transparent; } } .todos { --margin-top: 50px; --has-todos: 0; position: relative; width: 100%; height: calc(100% - (var(--margin-top) + (var(--add-todo-active) * 100px))); margin-top: calc(var(--margin-top) + (var(--add-todo-active) * 100px)); display: grid; transition: margin-top .3s, height .3s; } .todos .todos-list { list-style: none; gap: 1rem; padding: 1rem; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr); align-items: center; justify-items: center; z-index: 5; } .todos .todos-list .todo-item { --completed: 0; --removed: 0; position: relative; background-color: var(--accent); padding: 1rem; width: max-content; border-radius: .6rem; display: flex; align-items: center; justify-content: center; box-shadow: -5px 5px 0px var(--dark-accent); transform: rotate(var(--rotation)) translateY(var(--top-offset)); } .todo-item .task-text { margin-right: 15px; position: relative; white-space: nowrap; } .todo-item .task-text::after { content: ''; position: absolute; width: calc(110% * var(--completed)); height: 3px; top: 50%; left: 0%; translate: 0% -50%; background-color: var(--dark-accent); transition: width .3s; } .todos .todo-item .todo-item-btn { --checked: 0; position: relative; width: 25px; aspect-ratio: 1; background-color: var(--accent); border: none; border-radius: 50%; cursor: pointer; transition: opacity .3s, filter .3s; } .todo-item .todo-item-btn:hover { z-index: 3; } .todo-item:has(.todo-item-btn:hover) .todo-item-btn:not(:hover) { opacity: .6; filter: blur(2px); } .todo-item .todo-item-btn:nth-of-type(1) { margin-right: -6px; z-index: 2; } .todo-item .todo-item-btn svg { position: absolute; inset: 0; opacity: calc(1 - var(--checked)); } .todo-item .todo-item-btn svg:last-of-type { opacity: var(--checked); } .todo-item .todo-item-btn input { position: absolute; inset: 0; appearance: none; opacity: 0; cursor: pointer; clip-path: circle(50%); } .todo-item .todo-item-btn:has(input:checked), .todo-item .todo-item-btn:active { --checked: 1; } .todo-item:has(.todo-item-btn input:checked) { --completed: 1; } .todos-list:not(:has(*))+.no-todos { --has-todos: 1; } .todos .no-todos { position: absolute; top: 50%; left: 50%; transform: rotate(4deg) translate(-50%, calc(-50% + (var(--add-todo-active) * 50px))); width: max-content; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-family: Kalam, sans-serif; font-size: 3rem; color: var(--light-accent); opacity: calc(var(--has-todos) * .5); pointer-events: none; z-index: 0; transition: opacity .3s, transform .3s; } .todos .no-todos svg { width: 30vmin; position: absolute; top: -45%; left: calc(100% + .2ch); transform-origin: 50% 100%; transform: rotate(-70deg); } .alien-link { --alien-hover: 0; color: slategray; position: fixed; bottom: 1rem; left: 1rem; width: 48px; aspect-ratio: 1; display: grid; place-items: center; z-index: 100; opacity: calc(.8 + (.2 * var(--alien-hover))); animation: app-start 5s linear 1 -2.5s; } @keyframes app-start { to { --alien-hover: 1; } } .alien-link::after { content: 'Click me !'; position: absolute; bottom: calc(100% - 10px); left: calc(100% - 10px); width: 100px; aspect-ratio: 2/1; background-color: color-mix(in srgb, slategray, dodgerblue); color: rgba(0 0 0 / .8); border-radius: 10px 10px 10px 0px; transform-origin: 0% 0%; transform: rotate(-2deg) translate(calc((1 - var(--alien-hover)) * -10px), calc((1 - var(--alien-hover)) * -10px)); display: flex; align-items: center; justify-content: center; text-align: center; white-space: nowrap; font-size: 1rem; font-weight: 600; opacity: var(--alien-hover); transition: opacity .3s, transform .5s; } :where(.x-link, .alien-link, ):is(:hover, :focus-visible) { --alien-hover: 1; } .alien-link svg { width: 75%; } </style> </head> <body> <div class="add-todo" popover="auto" id="add-todo-popover"> <div class="inner"> <header class="header"> <h1>To-do List <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M8.38358 3C8.75808 3 9.06166 3.31153 9.06166 3.69582V3.92169C9.10586 3.91015 9.15023 3.89901 9.19476 3.88829C11.0399 3.44416 12.9601 3.44416 14.........完整代码请登录后点击上方下载按钮下载查看
网友评论0