svg+css实现昼夜切换按钮点击切换效果代码
代码语言:html
所属分类:其他
代码描述:svg+css实现昼夜切换按钮点击切换效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { min-height: 100vh; display: flex; justify-content: center; align-items: center; background: #FFF; transition: all 0.4s ease; } body.dark { background: #000; } * { box-sizing: border-box; } .appearance { cursor: pointer; -webkit-tap-highlight-color: transparent; } .appearance svg path { transform-origin: center; transition: all 0.6s ease; transform: translate3d(0, 0); backface-visibility: hidden; } .appearance svg path.sun { stroke: white; transform: scale(0.4) rotate(60deg); opacity: 0; } .appearance svg path.moon { stroke: black; opacity: 1; } .appearance.switch svg path.sun { transform: scale(1) rotate(0); opacity: 1; } .appearance.switch svg path.moon { transform: scale(0.4) rotate(-60deg); opacity: 0; } </style> </head> <body > <div class="appearance"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d.........完整代码请登录后点击上方下载按钮下载查看
网友评论0