Hamburger icon not showing on mobile - html

I have a navbar on my Django application. The code for it is below.
.nav-header {
height: 75px;
width: 100%;
float: left;
background: #2e2e2e;
padding: 0 20px;
color: #fff;
margin-bottom: 25px;
border-bottom: 2px solid black;
}
.brand-logo {
max-width: 75px;
float: left;
padding: 14px 0px;
}
.brand-logo img {
max-width: 100%;
}
.navigation {
margin: 0px;
float: right;
}
.navigation li {
list-style: none;
float: left;
}
.navigation li a {
color: #fff;
padding: 28px 15px;
text-transform: uppercase;
text-align: center;
display: block;
text-decoration: none;
}
.navigation li a i {
width: 100%;
font-size: 20px;
margin-bottom: 7px;
}
.show-menu-btn,
.hide-menu-btn {
transition: 0.4s;
font-size: 30px;
cursor: pointer;
display: none;
z-index: 2;
}
.show-menu-btn {
margin: 0px;
margin-top: 15px;
float: right;
}
.show-menu-btn i {
line-height: 100px;
}
.navigation a:hover,
.show-menu-btn:hover,
.hide-menu-btn:hover {
color: #00ff0a;
}
#toggle-btn {
position: absolute;
visibility: hidden;
z-index: -1111;
}
#media screen and (max-width: 767px) {
.show-menu-btn,
.hide-menu-btn {
display: block;
}
.navigation {
position: fixed;
width: 100%;
height: 100vh;
background: #2e2e2e;
top: -100%;
left: 0;
padding: 50px 0px;
transition: 1s;
z-index: 1;
}
.navigation li {
width: 100%;
}
.navigation li a {
padding: 15px 15px;
text-align: left;
}
.navigation li a i {
width: auto;
font-size: 20px;
}
.hide-menu-btn {
position: absolute;
top: 15px;
right: 20px;
}
#toggle-btn:checked ~ nav .navigation {
top: 0px;
}
}
<div class="container">
<input type="checkbox" id="toggle-btn">
<label for="toggle-btn" class="show-menu-btn"><i class="fas fa-bars"></i></label>
<nav>
<ul class="navigation">
<li><i class="fas fa-house-damage"></i> Home</li>
{% if request.user.is_authenticated %}
<li><i class="fas fa-sign-out-alt"></i> Sign Out</li>
{% else %}
<li><i class="fas fa-sign-in-alt"></i> Sign In</li>
<li><i class="fas fa-user-plus"></i> Sign Up</li>
{% endif %}
<label for="toggle-btn" class="hide-menu-btn"><i class="fas fa-times"></i></label>
</ul>
</nav>
</div>
When I test it locally in google chrome on my PC using the device toolbar, it works completely fine. When I deploy it to my Heroku server, the hamburger icon does not show.
The label is there it just is not visible. When I try to randomly tap the screen in the area where it is supposed to be, it works but still does not show.

Related

Fixed position html css sidebar scrolls in mobile view when not supposed to

I am currently building out my portfolio, and while working on the sidebar and testing for mobile responsivness, i ran into a small problem.
i have a div that acts as my sidebar, it has a position fixed, with a top and left 0. and in desktop view, it stays on scroll and works as i would expect. however through the inspect tab, and mobile view, the sidebar scrolls with the page. Code is attached below, in a perfect world i would be able to keep the sidebar where it is supposed to be in the mobile view. and this is specific to the mobile view, if you just shrink the main window to the media query width, it works as expected. Thanks!!
EDIT:
What iwant it to look like: https://youtu.be/w3AT3WHHL4o
what it looks like: https://youtu.be/kbfS8vBKAlU
<div class="side-nav">
<a href="#home" class="logo">
<img class="logo-img" src="Images/Logo.png">
<img class="icon-img" src="Images/Icon.png">
</a>
<ul class="nav-links">
<li><i class="fa-solid fa-user scrollLink"></i><p>About</p></li>
<li><i class="fa-solid fa-folder scrollLink"></i><p>Projects</p></li>
<li><i class="fa-solid fa-file scrollLink"></i><p>Resume</p></li>
<div class="active"></div>
</ul>
</div>
<style>
.side-nav {
width: 250px;
height: 100vh;
background: #9E9E9E;
position: fixed;
top: 0;
left: 0;
padding: 20px 30px;
}
.logo {
display: block;
margin-bottom: 130px;
}
.logo-img {
display: block;
width: 190px;
}
.icon-img {
display: none;
}
.nav-links {
list-style: none;
position: relative;
}
.nav-links li {
padding: 10px 0;
}
.nav-links li a {
color: white;
text-decoration: none;
padding: 10px 14px;
display: flex;
align-items: center;
}
.nav-links li a i {
font-size: 22px;
margin-right: 20px;
}
.active {
background: white;
width: 100%;
height: 47px;
position: absolute;
left: 0;
top: 4%;
z-index: -1;
border-radius: 6px;
box-shadow: 0 5px 10px rgba(255, 255, 255, 0.4);
display: none;
transition: top 0.5s;
}
.nav-links li:hover a {
color: #9E9E9E;
transition: 0.3s;
}
.nav-links li:hover ~ .active {
display: block;
}
.nav-links li:nth-child(1):hover ~ .active{
top: 4%;
}
.nav-links li:nth-child(2):hover ~ .active{
top: 35.9%;
}
.nav-links li:nth-child(3):hover ~ .active{
top: 69.2%;
}
#media only screen and (max-width: 600px){
.side-nav {
width: 110px;
}
.nav-links li a p {
display: none;
}
.nav-links li a i {
margin-right: 0;
}
.nav-links li a {
justify-content: center;
}
.logo-img {
display: none;
}
.icon-img {
display: block;
}
}
</style>
i have commented the things i added. i am sorry i would not be able to explain because you setup is very messy & need to refactored.
.side-nav {
width: 250px;
height: 100vh;
background: #9E9E9E;
position: fixed;
top: 0;
left: 0;
padding: 20px 30px;
}
.logo {
display: block;
margin-bottom: 130px;
}
.logo-img {
display: block;
width: 190px;
}
.icon-img {
display: none;
}
.nav-links {
list-style: none;
position: relative;
}
.nav-links li {
padding: 10px 0;
}
.nav-links li a {
color: white;
text-decoration: none;
padding: 10px 14px;
display: flex;
align-items: center;
}
.nav-links li a i {
font-size: 22px;
margin-right: 20px;
}
.active {
background: white;
width: 100%;
height: 47px;
position: absolute;
left: 0;
top: 4%;
z-index: -1;
border-radius: 6px;
box-shadow: 0 5px 10px rgba(255, 255, 255, 0.4);
display: none;
transition: top 0.5s;
}
.nav-links li:hover a {
color: #9E9E9E;
transition: 0.3s;
}
.nav-links li:hover~.active {
display: block;
}
.nav-links li:nth-child(1):hover~.active {
top: 4%;
}
.nav-links li:nth-child(2):hover~.active {
top: 35.9%;
}
.nav-links li:nth-child(3):hover~.active {
top: 69.2%;
}
#media only screen and (max-width: 600px) {
.side-nav {
width: 100px;
height: 70vh;
padding: 2px 3px; /*i added*/
display: flex; /*i added*/
flex-direction: column; /*i added*/
align-items: space-between; /*i added*/
}
.nav-links li a i {
font-size: 12px; /*i added*/
margin-right: 0px; /*i added*/
}
.logo {
display: block;
margin-bottom: 30px; /*i added*/
}
.nav-links li a p {
display: none;
}
.nav-links li a i {
margin-right: 0;
}
.nav-links li a {
justify-content: flex-start; /*i added*/
}
.logo-img {
display: none;
}
.icon-img {
display: block;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" rel="stylesheet" />
<div class="side-nav">
<a href="#home" class="logo">
<img class="logo-img" src="Images/Logo.png">
<img class="icon-img" src="Images/Icon.png">
</a>
<ul class="nav-links">
<li><i class="fa-solid fa-user scrollLink"></i><p>About</p></li>
<li><i class="fa-solid fa-folder scrollLink"></i><p>Projects</p></li>
<li><i class="fa-solid fa-file scrollLink"></i><p>Resume</p></li>
<div class="active"></div>
</ul>
</div>

Why is my drop down menu not Working on HTML,CSS

I have no idea why my drop down menu that im trying to include is not appearing and i cant seem to find whats wrong, i saw that the only way for it to appear is to remove hidden but if i do that i doesnt look how i want it to, yet if i have the hidden when i hover over the servicios tab its not showing anything which i cannot find the reason on why it doesnt appear there
{
margin: 0;
padding: 0;
font-family: sans-serif;
}
.hero{
height: 100vh;
background-image: linear-gradient(rgba(0,0,0,0.8), rgba(0,0,0,0.6)), url(bp.jpg);
background-position: center;
background-size: cover;
overflow-x: hidden;
position: relative;
}
.nav_bar{
display: flex;
padding: 40px 120px;
}
.nav-logo img{
width: 135px;
}
.nav_links{
flex: 1;
}
.nav_links ul{
margin-left: 50px;
display: inline;
list-style: none;
}
.nav_links ul li{
list-style: none;
display: inline-block;
padding: 8px 25px;
}
.nav_links ul a{
color: #fff;
text-decoration: none;
font-size: 18px;
}
.nav_links ul li::after{
content: '';
width: 0;
height: 2px;
background: red;
display: block;
margin: auto;
transition: 0.45s;
}
.nav_links ul li:hover::after{
width: 100%;
}
.btn{
padding: 10px 10px;
border: 0;
background: red;
font-weight: bold;
cursor: pointer;
}
.nav_links .btn{
float: center;
}
.frase{
margin: 100px 130px;
color: #fff;
}
.frase h1{
font-size: 56px;
margin-bottom: 30px;
}
.vertical_bar{
height: 100%;
background: red;
top: 0;
left: 0;
position: absolute;
}
.icono_busqueda{
height: 60%;
width: 80px;
}
.icono_busqueda .fa{
margin: 45px 23px;
display: block;
color: white;
font-size: 30px;
cursor: pointer;
}
.iconos_sociales{
height: 60%;
width: 80px;
}
.iconos_sociales .fa{
margin: 45px 23px;
display: block;
color:black;
font-size: 30px;
cursor: pointer;
}
.iconos_sociales{
height: 35%;
width: 80px;
background: white;
text-align: center;
padding-top: 27%;
bottom: 0;
position: absolute;
}
.iconos_sociales .fa{
margin: 15px 15px;
display: block;
padding: 8px;
border: 1px solid black;
border-radius: 0;
cursor: pointer;
}
*{
margin: 0;
padding: 0;
}
.sub_menu_ser
{
display: none;
}
.nav_links ul li:hover .sub_menu_ser
{
display: block;
position: absolute;
background: red;
margin-top: 15px;
margin-left: -15px;
}
.nav_links ul li:hover .sub_menu_ser ul
{
display: block;
margin: 10px;
}
.nav_links ul li:hover .sub_menu_ser li
{
width: 150px;
padding: 10px;
border-bottom: 1px dotted white;
background: transparent;
border-radius: 0;
text-align: left;
}
:last-child
{
border-bottom: none;
}
.nav_links ul li:hover .sub_menu_ser ul li a:hover
{
color: red;
}
<html>
<head>
<title> Animal Care</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="hero">
<div class="nav_bar">
<div class="nav_logo">
<img src="logo.png">
</div>
<div class="nav_links">
<ul>
<li>Sobre Nosotros</li>
<li>Servicios</li>
<div class="sub_menu_ser">
<ul>
<li>Peluqueria</li>
<li>Veterinario</li>
<li>Cirugia</li>
<li>Limpieza</li>
</ul>
</div>
<li>Contacto</li>
</ul>
<button type="button" class="btn">Registrarse</button>
</div>
<div class="frase">
<h1>Cuidando a Nuestros <br> Mas Queridos</h1>
<button type="button" class="btn">Explorar</button>
</div>
<div class="vertical_bar">
<div class="icono_busqueda">
<i class="fa fa-search"></i>
<i class="fa fa-list"></i>
</div>
<div class="iconos_sociales">
<i class="fa fa-facebook"></i>
<i class="fa fa-instagram"></i>
<i class="fa fa-twitter"></i>
<i class="fa fa-envelope-o"></i>
</div>
</div>
</div>
</body>
</html>
Code to hide the element:
#element {
display: none;
}
Code to show the element:
#element:hover {
display: block;
}

My responsive navbar is not working. I am not able to link on some links

I am not able to click on HOME, CATEGORIES and LOGIN link.
The links which are not collapsing with image, they're clickable. Otherwise it won't click.
It was working fine initially when there wasn't any content.
I tried adding javascript and doing it the other way but I was still facing the same issue.
nav {
background: #14213d;
height: 80px;
width: 100%;
}
label.logo {
color: #ffffff;
font-size: 30px;
line-height: 80px;
padding: 0 140px;
font-weight: 600;
font-family: 'Poppins', sans-serif;
}
nav ul {
float: right;
margin-right: 60px;
}
nav ul li {
display: inline-block;
line-height: 80px;
margin: 0 2px;
}
nav ul li a {
color: #d1d1d1;
font-weight: 500;
font-size: 15px;
padding: 7px 13px;
border-radius: 3px;
/* text-transform: uppercase; */
font-family: 'Poppins', sans-serif;
}
a.active,
a:hover {
background: #263e72;
transition: .5s;
}
.checkbtn {
font-size: 30px;
color: white;
float: right;
line-height: 80px;
margin-right: 40px;
cursor: pointer;
display: none;
}
#check {
display: none;
}
#media (max-width: 952px) {
label.logo {
font-size: 27px;
padding-left: 25px;
}
nav ul li a {
font-size: 16px;
}
.text {
font-size: 21px
}
}
#media (max-width: 858px) {
.checkbtn {
display: block;
margin-right: 40px;
}
ul {
position: fixed;
width: 100%;
height: 100vh;
background: #e5e5e5;
top: 80px;
left: -100%;
text-align: center;
transition: all .5s;
}
nav ul li {
display: block;
margin: 50px 0;
line-height: 30px;
}
nav ul li a {
font-size: 20px;
color: #4d4a46;
}
a:hover,
a.active {
background: none;
color: #4d4a46;
background: #c8d1e4;
}
#check:checked~ul {
left: 0;
}
.text {
font-size: 11px
}
}
<nav>
<input type="checkbox" id="check">
<label for="check" class="checkbtn">
<i class="fa fa-bars"></i>
</label>
<label class="logo"><i id="logo" class="fa fa-book"></i> Book Shoppers</label>
<ul>
<li><a class="active" href="#"><i class="fa fa-home"></i> HOME</a></li>
<li><i class="fa fa-chevron-circle-down"></i> CATEGORIES</li>
<li><i class="fa fa-sign-in"></i> LOGIN</li>
<li><i class="fa fa-heart"></i> WISHLIST</li>
<li><i class="fa fa-phone"></i> CUSTOMER SUPPORT</li>
</ul>
</nav>
Try adding z-index in the nav of the css file.
This will solve the problem
nav {
background: #14213d;
height: 80px;
width: 100%;
z-index: 2;
}

CSS Style Side Navbar with Icons

I am currently building a dashboard for a project I'm workig on - as i didn't touch css for years now i kinda struggle with a side Nav Bar.
<div id="nav">
<div id="nav-wrapper">
<ul>
<li><i class="fas fa-home"></i></li>
<li><i class="fas fa-home"></i></li>
<li><i class="fas fa-home"></i></li>
<li><i class="fas fa-home"></i></li
<li><i class="fas fa-home"></i></li>
</ul>
</div> <!--End of nav-wrapper-->
</div> <!--End of nav-->
#nav{
width: 10%;
height: 100%;
background-color: #273138;
position: fixed;
a{
color: white;
text-decoration: none;
}
#nav-wrapper{
padding: 30px 0px 30px;
font-size: 2em;
}
}
This is what my navbar basicaly looks like. I want the elements centered and rounded - similarly to the style discord uses for it's server list (Link)
Any idea how i can build this in css?
I have created a solution in JSFiddle
JSFiddle
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
}
#nav {
width: 10%;
height: 100%;
background-color: #273138;
position: fixed;
}
#nav-wrapper {
font-size: 1.5em;
}
#nav-wrapper ul {
display: block;
}
#nav-wrapper li {
list-style: none;
background-color: #d24d57;
height: 50px;
width: 50px;
margin: 10px auto;
border-radius: 100%;
text-align: center;
line-height: 50px;
}
#nav-wrapper li a {
color: white;
text-decoration: none;
}
I have made something, does it looks like what you want?
body{
margin: 0px;
}
#nav {
height: 100%;
width: 10%;
background-color: #273138;
position: fixed;
}
#nav-wrapper{
display: flex;
justify-content: center;
align-items: center;
}
ul{
list-style-type: none;
margin: 0px;
padding: 0px;
}
li{
margin-top: 2px;
background-color: orange;
border-radius: 100%;
padding: 5px;
font-size: 2em;
}
a{
color: white;
text-decoration: none;
}
plus, this is not recommended to nest classes
I hope this can help you.
body {
background-color: #36393e;
}
#nav {
width: auto;
height: 100%;
background-color: #1f2125;
position: fixed;
}
#nav ul {
list-style: none;
padding-left: 0;
margin: 0;
position: relative;
padding-top: 20px;
padding-bottom: 20px;
}
#nav ul::before {
position: absolute;
content: '';
top: 15px;
left: 25%;
background-color: #2E3136;
width: 50%;
height: 1px;
}
#nav ul::after {
position: absolute;
content: '';
bottom: 15px;
left: 25%;
background-color: #2E3136;
width: 50%;
height: 1px;
}
#nav ul li {
display: flex;
flex-direction: column;
justify-items: center;
align-items: center;
margin: 10px;
}
#nav a {
background-color: #2E3136;
border-radius: 100%;
padding: .5em;
color: white;
text-decoration: none;
width: 30px;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
}
#nav a {
animation: hover-out 0.6s ease;
}
#nav a:hover, #nav a:focus {
animation: hover-in 0.8s ease forwards;
}
#nav a i {
font-size: 1em;
}
#nav #nav-wrapper {
font-size: 2em;
}
#keyframes hover-in {
0% {
border-radius: 100%;
background-color: #2E3136;
}
40% {
border-radius: 12px;
}
70% {
border-radius: 16.7px;
}
80% {
background-color: #7289DA;
}
100% {
border-radius: 15px;
background-color: #7289DA;
}
}
#keyframes hover-out {
0% {
border-radius: 15px;
background-color: #7289DA;
}
45% {
border-radius: 70%;
background-color: #2E3136;
}
65% {
border-radius: 70%;
}
75% {
border-radius: 75%;
}
100% {
border-radius: 100%;
}
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div id="nav">
<div id="nav-wrapper">
<ul>
<li><i class="fa fa-home"></i></li>
<li><i class="fa fa-home"></i></li>
<li><i class="fa fa-home"></i></li>
<li><i class="fa fa-home"></i></li>
<li><i class="fa fa-home"></i></li>
</ul>
</div> <!--End of nav-wrapper-->
</div> <!--End of nav-->

The dropdown menu does not appear correctly

I made this page
* {
box-sizing: border-box;
}
/* Navbar */
nav {
background: #4D636F;
max-height: 51px;
margin: 0;
overflow: hidden;
padding: 0;
}
nav a {
text-decoration: none;
}
nav span.badge {
position: absolute;
font-size: 12px;
top: 5px;
right: 6;
background-color: #4CAF50;
padding: 1px 4px;
border-radius: 50%;
}
nav .logo {
background: #3A4B53;
float: left;
font-size: 18px;
padding: 12px 18px;
color: #fff;
cursor: pointer;
}
nav .logo i {
margin-right: 13px;
}
nav ul {
list-style-type: none;
margin: 0;
padding-top: 12px;
}
nav ul li {
display: inline;
}
nav ul li a {
color: #fff;
padding: 12px 18px;
font-size: 18px;
transition: all 0.2s ease;
}
nav ul li a:hover {
color: #444;
background-color: white;
}
nav .right {
float: right;
}
nav .right a img {
width: 25px;
height: 25px;
border-radius: 50%;
margin-bottom: 8px;
}
li.dropdown {
position: relative;
}
.dropdown-menu {
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
padding: 0;
top: 20px;
z-index: 1;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2)
}
.dropdown-menu a {
color: #444;
text-align: left;
padding: 0;
display: block;
}
/* Navbar ends */
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<nav id="myNav">
<div class="logo">
<span><i class="fa fa-home" aria-hidden="true"></i>Logo</span>
</div>
<ul>
<li><i class="fa fa-globe" aria-hidden="true"></i></li>
<li><i class="fa fa-user" aria-hidden="true"></i></li>
<li><i class="fa fa-envelope" aria-hidden="true"></i></li>
<li class="dropdown">
<a href="#" style="position: relative;"><i class="fa fa-bell"></i>
<span class="badge">3</span>
</a>
<div class="dropdown-menu">
One
One
One
</div>
</li>
<li class="right"><img src="images/profile.png" align="middle"></li>
</ul>
</nav>
The problem as viewed is that the dropdown-menu does not appear correctly.
I made it it absolute and it has z-index : 1 :(
I know that I didn't make it hoverable but I want it to appear then I will handle it.
I don't feel anything wrong with the code, but the output says otherwise.
What I did wrong? And what should I do to make it right?
Your problem is the overflow: hidden in the nav
* {
box-sizing: border-box;
}
/* Navbar */
nav {
background: #4D636F;
max-height: 71px;
margin: 0;
padding: 0;
}
nav a {
text-decoration: none;
}
nav span.badge {
position: relative;
font-size: 12px;
top: -11px;
height: 15px;
background-color: #4CAF50;
padding: 2px 6px;
border-radius: 50%;
}
nav .logo {
background: #3A4B53;
float: left;
font-size: 18px;
padding: 12px 18px;
color: #fff;
cursor: pointer;
}
nav .logo i {
margin-right: 13px;
}
nav ul {
list-style-type: none;
margin: 0;
line-height: 45px
}
nav ul li {
display: inline;
}
nav ul li a {
color: #fff;
padding: 12px 18px;
font-size: 18px;
transition: all 0.2s ease;
}
nav ul li a:hover {
color: #444;
background-color: white;
}
nav .right {
float: right;
}
nav .right a img {
width: 25px;
height: 25px;
border-radius: 50%;
margin-bottom: 8px;
}
li.dropdown {
position: relative;
}
.dropdown-menu {
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
padding: 0;
top: 31px;
z-index: 1;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2)
}
.dropdown-menu a {
color: #444;
text-align: left;
padding: 0;
display: block;
}
/* Navbar ends */
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<nav id="myNav">
<div class="logo">
<span><i class="fa fa-home" aria-hidden="true"></i>Logo</span>
</div>
<ul>
<li><i class="fa fa-globe" aria-hidden="true"></i></li>
<li><i class="fa fa-user" aria-hidden="true"></i></li>
<li><i class="fa fa-envelope" aria-hidden="true"></i></li>
<li class="dropdown">
<a href="#" style="position: relative;"><i class="fa fa-bell"></i>
<span class="badge">3</span>
</a>
<div class="dropdown-menu">
One
One
One
</div>
</li>
<li class="right"><img src="images/profile.png" align="middle"></li>
</ul>
</nav>
.dropdown-menu {
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
padding: 0;
top: 31px;
z-index: 1;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
max-height: 71px;
overflow-y: hidden;
}
.dropdown-menu :hover {
overflow-y: visible;
}
I used that a couple of times on my web page.