css实现网页滚动粘性导航条效果代码
代码语言:html
所属分类:菜单导航
代码描述:css实现网页滚动粘性导航条效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/reset.min.css">
<style>
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
:root {
--header-bg: hsl(196, 10%, 20%);
--header-bg-sticky: hsl(196, 10%, 30%, .98);
--header-text: hsl(0, 5%, 96%);
--header-height: 48px;
--header-width-sticky: min(600px, 100%) ;
--nav-gap: 1px;
--nav-item-space: 8px;
--content-space: 64px 32px;
--btn-space: 16px 32px;
--btn-radius: 99em;
--hero-gap: 16px;
--footer-bg: hsl(196, 10%, 20%);
--footer-text: hsl(0, 5%, 96%);
--footer-height: 48px;
}
html {
font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
}
header {
background-color: hsl(196, 10%, 20%);
background-color: var(--header-bg);
position: -webkit-sticky;
position: sticky;
top: 0;
overflow: visible;
margin: 0 auto;
height: 48px;
height: var(--header-height)
}
header ul {
display: grid;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
justify-items: center;
place-items: center;
height: 100%;
list-style: none;
grid-auto-flow: column;
grid-gap: 1px;
gap: 1px;
grid-gap: var(--nav-gap);
gap: var(--nav-gap);
margin: 0 auto;
padding: 0;
width: min(900px, 100%);
}
header li {
margin: 0;
padding: 8px;
padding: var(--nav-item-space);
}
header a:link,header a:visited {
display: block;
text-align: center;
text-decoration: none;
color: hsl(0, 5%, 96%);
color: var(--header-text);
font-size: 14px;
font-weight: 500;
text-transform: uppercase;
}
header a:-webkit-any-link {
display: block;
text-align: center;
text-decoration: none;
color: hsl(0, 5%, 96%);
color: var(--header-text);
font-size: 14px;
font-weight: 500;
text-transform: uppercase;
}
header a:-moz-any-link {
display: block;
text-align: center;
text-decoration: none;
color: hsl(0, 5%, 96%);
color: var(--header-text);
font-size: 14px;
font-weight: 500;
text-transform: uppercase;
}
header a:any-link {
display: block;
text-align: center;
text-decoration: none;
color: hsl(0, 5%, 96%);
color: var(--header-text);
font-size: 14px;
font-weight: 500;
text-transform: uppercase;
}
.hero {
display: grid;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
justify-items: center;
place-items: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
place-content: center;
grid-gap: 16px;
gap: 16px;
grid-gap: var(--hero-gap);
gap: var(--hero-gap);
aspect-ratio: 16 / 9;
ba.........完整代码请登录后点击上方下载按钮下载查看
网友评论0