From 7ade1089f4abe3d2e6e9cbf3b9b9e7ee341f0960 Mon Sep 17 00:00:00 2001 From: Mohasin-Haque Date: Tue, 8 Feb 2022 08:19:54 +0530 Subject: [PATCH] Feat - added responsive navbar in navbars --- pages/navbar.html | 25 +++++++ styles/main.css | 1 + styles/navbar.css | 174 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 styles/navbar.css diff --git a/pages/navbar.html b/pages/navbar.html index 3a4adf9..2a0103e 100644 --- a/pages/navbar.html +++ b/pages/navbar.html @@ -48,6 +48,7 @@

Navbar

Navbars are one of the most important part of a website. Here user will find the links/buttons where he want to go or access easily.

+

Navbar on Top

Its a normal navbar which we generally use in our sites. We keep some links and our logo on it. You can include nav class as @@ -71,6 +72,30 @@

Navbar on Top

+ + +

Responsive Navbar on Top

+

Its a responsive navbar which we generally use in our sites. We keep + some + links and our logo on it. This responsive navbar will hide some options when screen size will decrease or + simply it changes to hamburgure. You can include nav class as + shown below.

+ + + \ No newline at end of file diff --git a/styles/main.css b/styles/main.css index 0554721..717b425 100644 --- a/styles/main.css +++ b/styles/main.css @@ -9,6 +9,7 @@ @import url("../styles/dialogue.css"); @import url("../styles/image.css"); @import url("../styles/input.css"); +@import url("../styles/navbar.css"); @import url("../styles/rating.css"); @import url("../styles/toast.css"); @import url("../styles/typography.css"); diff --git a/styles/navbar.css b/styles/navbar.css new file mode 100644 index 0000000..7042212 --- /dev/null +++ b/styles/navbar.css @@ -0,0 +1,174 @@ +.navbar-responsive { + padding: 1rem; + background-color: var(--body-background-color); + color: var(--text-color-black); + box-shadow: var(--box-shadow-down); + padding: 0.3rem 1.2rem; + margin-bottom: 1rem; +} + +ul { + list-style-type: none; +} + +a { + color: var(--text-color-black); + text-decoration: none; +} + +.menu li { + font-size: 1.2rem; + font-weight: 500; + padding: 0.9rem 0.3rem; +} + +.menu li a { + display: block; +} + +.logo a { + font-size: 1.4rem; + font-weight: 500; + color: var(--primary-color); +} + +/* Mobile Menu */ +.menu { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + align-items: center; +} + +.toggle { + order: 1; +} + +.item.button { + order: 2; +} + +.item { + width: 100%; + text-align: center; + order: 3; + display: none; +} + + +.item.active { + display: block; +} + +.toggle { + cursor: pointer; +} + +.bars { + background: var(--hover-color); + display: inline-block; + height: 2px; + position: relative; + width: 1.1rem; +} + +.bars::before, +.bars::after { + background: var(--hover-color); + content: ""; + display: inline-block; + height: 2px; + position: absolute; + width: 1.1rem; +} + +.bars::before { + top: 0.3rem; +} + +.bars::after { + top: -0.3rem; +} + +/* Tablet Menu */ +@media all and (min-width: 468px) { + .menu { + justify-content: center; + } + + .logo { + flex: 1; + } + + .item.button { + width: auto; + order: 1; + display: block; + } + + .toggle { + order: 2; + } + + .button.secondary { + border: 0; + } + + .button a { + text-decoration: none; + padding: 0.4rem 0.9rem; + background: var(--primary-color); + border: 1px solid var(--primary-color); + border-radius: 50em; + } + + .button.secondary a { + background: transparent; + } + + .button a:hover { + transition: all 0.25s; + } + + /* not pseudo class:- anything that is not the class of secondary a:hover and change the background */ + + .button:not(.secondary) a:hover { + background: var(--secondary-color); + border-color: var(--hover-color); + } + + .button.secondary a:hover { + color: var(--hover-color); + } +} + +@media all and (min-width: 768px) { + .item { + display: block; + width: auto; + } + + .toggle { + display: none; + } + + .logo { + order: 0; + } + + .item { + order: 1; + } + + .button { + order: 2; + } + + .menu li { + padding: 0.9rem 0.6rem; + } + + .menu li.button { + padding-right: 0; + } +}