css实现自适应头部导航条效果代码
代码语言:html
所属分类:菜单导航
代码描述:css实现自适应头部导航条效果代码,未使用框架,纯css+原生js实现
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> * { margin: 0; padding: 0; box-sizing: border-box; } html { font-size: 62.5%; font-family: 'Roboto', sans-serif; } li { list-style: none; } a { text-decoration: none; } span { color: white; } img { height: 40px; width: 40px; object-fit: cover; border-radius: 50%; vertical-align: top; } .header { border-bottom: 1px solid #e2e8f0; } .navbar { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; z-index: 999; } .bar { display: block; width: 25px; height: 3px; margin: 5px auto; -webkit-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; background-color: #101010; } .hamburger { display: none; } .bar { display: block; width: 25px; height: 3px; margin: 5px auto; -webkit-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; background-color: #101010; } .nav-menu { display: flex; justify-content: space-between; align-items: center; } .nav-item { margin-left: 5rem; } .nav-link { font-size: 1.6rem; font-weight: 400; color: #475569; } .nav-link:hover { color: #482ff7; } .nav-logo { font-size: 2.1rem; font-weight: 500; color: #482ff7; } @media only screen and (max-width: 768px) { .nav-menu { position: fixed; left: -120%; top: 6.5rem; flex-direction: column; background-color: #fff; width: 100%; border-radius: 10px; text-align: center; transition: 0.3s; box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05); } .nav-menu.active { left: 0; } .nav-item { width: 100%; margin: 0; border-bottom: 1px solid #f3f4f6; } .nav-link { display: block; padding: 2.5rem 0; } .hamburger { display: block; cursor: pointer; } .hamburger.active .bar:nth-child(2) { opacity: 0; } .hamburger.active .bar:nth-child(1) { -webkit-transform: translateY(8px) rotate(45deg.........完整代码请登录后点击上方下载按钮下载查看
网友评论0