css变量实现暗黑模式切换效果
代码语言:html
所属分类:布局界面
代码描述:css变量实现暗黑模式切换效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> @import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap'); * { padding: 0; margin: 0; box-sizing: border-box; } /*Default Theme*/ .default { --text-color: #000000; --background: #ffffff; --neutral: rgba(229,229,229,0.3); } /*Dark Theme*/ .dark { --text-color: #ffffff; --background: #141945; --neutral: rgba(229,229,229,0.3); } .container { width: 274px; height: 487.33px; padding: 20px; box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22); position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); background-color: var(--background); border-radius: 25px; color: var(--text-color); display: flex; flex-direction: column; font-family: 'Open Sans'; } .header { width: 100%; display: flex; flex-direction: row; justify-content: space-between; align-items: center; } #search-bar { height: 33.33px; width: 186.667px; border-radius: 16.667px; padding: 16.667px; border: none; background-color: var(--neutral); outline: none; } #search-bar::placeholder { color: var(--text-color); } #toggle-theme { padding: 2px 4px; line-height: 20px; border-radius: 4px; border: none; background-color: var(--text-color); color: var(--background); .........完整代码请登录后点击上方下载按钮下载查看
网友评论0