svg+css实现自适应黑白主题切换的顶部菜单效果代码

代码语言:html

所属分类:菜单导航

代码描述:svg+css实现自适应黑白主题切换的顶部菜单效果代码

代码标签: svg css 自适应 黑白 主题 切换 顶部 菜单

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" class="dark">

<head>
  <meta charset="UTF-8">
  
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.5.0.css">
  
<style>


*,
*:after,
*:before {
	box-sizing: border-box;
}

:root {
	--bg: hsl(0 0% 90%);
	--nav: hsl(0 0% 100%);
	--color: hsl(0 0% 30%);
}

:root.dark {
	--bg: hsl(0 0% 0%);
	--nav: hsl(0 0% 14%);
	--color: hsl(0 0% 90%);
}

body {
	place-items: center;
	min-height: 100vh;
	font-family:  "SF Pro Text", "SF Pro Icons", "AOS Icons", "Helvetica Neue", Helvetica, Arial, sans-serif, system-ui;
	background: var(--bg);
	color: var(--color);
}

nav {
	height: 60px;
	position: sticky;
	top: 0;
	left: 0;
	right: 0;
	text-transform: uppercase;
	font-family: monospace;
	font-size: 14px;
	background: var(--nav);
}

.nav__content {
	width: 1100px;
	display: flex;
	max-width: calc(100% - 2rem);
	margin: 0 auto;
	height: 100%;
	gap: 1rem;
	position: relative;
	justify-content: space-between;
	background: var(--nav);
}

.nav__control {
	width: 60px;
}

label {
	display: grid;
	place-items: center;
	height: 100%;
	width: 100%;
	cursor: pointer;
}

.nav__control svg {
	width: 24px;
	stroke-width: 2.5;
	rotate: calc(var(--active-nav, 0) * 45deg);
	transition: rotate var(--speed);
}

input:focus-visible + label {
	outline: 1px solid red;
}

.nav__content > a svg {
	width: 32px;
/*	color: hsl(0 0% 15%);*/
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

.nav__options a {
	position: relative;
	padding: 1rem 2rem;
	height: 60px;
}

.nav__options svg {
	height: 16px;
	stroke-width: 2.5px;
}

.nav__options {
	position: absolute;
	right: -1rem;
	top: 100%;
	background: var(.........完整代码请登录后点击上方下载按钮下载查看

网友评论0