svg+css实现星级评分打分动画效果代码
代码语言:html
所属分类:星级评分
代码描述:svg+css实现星级评分打分动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> * { box-sizing: border-box; } :root { --background-color: hsl(208.7, 100%, 9%); --on-color: #ffc107; --off-color: hsl(208.7, 50%, 25%); background-color: var(--background-color); } body { margin: 0; display: flex; place-items: center; min-width: 320px; min-height: 100vh; display: flex; align-items: center; justify-content: center; } .rating { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 0 4px; height: 40px; } .rating-button { appearance: none; background: none; outline: none; border: none; padding: 0; height: 100%; cursor: pointer; --transition-delay: 0s; } .rating--animatable .rating-button { transition: 0.4s cubic-bezier(0.23, 1, 0.32, 1) transform; } .rating-button:active { transform: scale(0.8); } .rating-button--active:active { transform: scale(1.1); } .star { transform: scale(0.5) rotate(0deg); height: 100%; color: var(--off-color); } .rating--animatable .star { transition: 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) all; transition-delay: var(--transition-delay); } .rating-button--active .star { transform: scale(0.9) rotate(360deg); color: var(--on-color); } </style> </head> <body > <div class="rating"> <button class="rating-button"> <svg class="star" viewBox="0 -10 511.98685 511" xmlns="http://www.w3.org/2000/svg" > <path d="m510.652344 185.902344c-3.351563-10.367188-12.546875-17.730469-23.425782-18.710938l-147.773437-13.417968-58.433594-136.769532c-4.308593-10.023437-14.121093-16.511718-25.023437-16.511718s-20.714844 6.488281-25.023438 16.535156l-58.433594 136.746094-147.796874 13.417968c-10.859376 1.003906-20.03125 8.34375-23.402344 18.710938-3.371094 10.367187-.257813 21.738281 7.957031 28.90625l111.699219 97.960937-32.9375 145.089844c-2.410156 10.667969 1.730468 21.695313 10.582031 28.09375 4.757813 3.4375 10.324219 5.1875 15.9375 5.1875 4.839844 0 9.640625-1.304687 13.949219-3.882813l127.46875-76.183593 127.421875 76.183593c9.324219 5.609376 21.078125 5.097657 29.910156-1.304687 8.855469-6.417969 12.992187-17.449219 10.582031-28.09375l-32.9375-145.089844 111.699219-97.941406c8.214844-7.1875 11.351563-18.539063 7.980469-28.925781zm0 0" fill="currentColor" /> </svg> </button> <button class="rating-button"> <svg class="star" viewBox="0 -10 511.98685 511" xmlns="http://www.w3.org/2000/svg" > <path d="m510.652344 185.902344c-3.351563-10.367188-12.546875-17.730469-23.425782-18.710938l-147.773437-13.417968-58.433594-136.769532c-4.308593-10.023437-14.121093-16.511718-25.023437-16.511718s-20.714844 6.488281-25.023438 16.535156l-58.433594 136.746094-147.796874 13.417968c-10.859376 1.003906-20.03125 8.34375-23.402344 18.710938-3.371094 10.367187-.257813 21.738281 7.957031 28.90625l111.699219 97.960937-32.9375 145.089844c-2.410156 10.667969 1.730468 21.695313 10.582031 28.09375 4.757813 3.4375 10.324219 5.1875 15.9375 5.1875 4.839844 0 9.640625-1.304687 13.949219-3.882813l127.46875-76.183593 127.421875 76.183593c9.324219 5.609376 21.078125 5.097657 29.910156-1.304687 8.855469-6.417969 12.992187-17.449219 10.582031-28.09375l-32.9375-145.089844 111.699219-97.941406c8.214844-7.1875 11.351563-18.539063 7.980469-28.925781zm0 0" fill="currentColor" /> </svg> </button> <button class="rating-button"> <svg class="star" viewBox="0 -10 511.98685 511" xmlns="http://www.w3.org/2000/svg" > <path d="m510.652344 185.902344c-3.351563-10.367188-12.546875-17.730469-23.425782-18.710938l-147.773437-13.417968-58.433594-136.769532c-4.308593-10.023437-14.121093-16.511718-25.023437-16.511718s-20.714844 6.488281-25.023438 16.535156l-58.433594 136.746094-147.796874 13.417968c-10.859376 1.003906-20.03125 8.34375-23.402344 18.710938-3.371094 10.367187-.257813 21.738281 7.957031 28.90625.........完整代码请登录后点击上方下载按钮下载查看
网友评论0