Close dropdown one when other is opened - html

I have created drop-down which is working properly but it's not closing when opening other. I need to close one when other is opened. It should be done through CSS only, no JS. So, I need a fix so all of them work independently. I have tried but couldn't do it. I am posting the HTML and CSS code below please have look. Please help me to fix it.
#import url('https://fonts.googleapis.com/css2?family=Roboto:wght#400;500;700;900&display=swap');
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
font-family: 'Roboto', sans-serif;
font-weight: 500;
font-size: 15px;
line-height: 1.4;
color: #fff;
background-color: #1f2029;
overflow-x: hidden;
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/1462889/pat-back.svg');
background-position: center;
background-repeat: repeat;
background-size: 4%;
width: 100%;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-pack: center;
justify-content: center;
padding-top: 100px;
padding-bottom: 300px;
}
.sec-center,
.sec-center1,
.sec-center2 {
position: relative;
max-width: 100%;
text-align: center;
z-index: 200;
display: inline-block;
margin-right: 5px;
}
[type="checkbox"]:checked,
[type="checkbox"]:not(:checked) {
position: absolute;
left: -9999px;
opacity: 0;
pointer-events: none;
}
.dropdown:checked+label,
.dropdown:not(:checked)+label,
.dropdown1:checked+label,
.dropdown1:not(:checked)+label,
.dropdown2:checked+label,
.dropdown2:not(:checked)+label {
position: relative;
font-family: calibri, sans-serif;
font-weight: 500;
font-size: 14px;
/* line-height: 2; */
/* height: 50px; */
transition: all 200ms linear;
/* border-radius: 4px; */
/* width: 220px; */
letter-spacing: 1px;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
align-items: center;
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
justify-content: center;
-ms-flex-pack: center;
text-align: center;
border: none;
background-color: transparent;
cursor: pointer;
color: #fff;
/* box-shadow: 0 12px 35px 0 rgb(255 235 167 / 15%); */
padding: 4px 20px;
border-right: 2px solid #fff;
border-radius: 50px;
}
.dropdown:checked+label:before,
.dropdown:not(:checked)+label:before,
.dropdown1:checked+label:before,
.dropdown1:not(:checked)+label:before,
.dropdown2:checked+label:before,
.dropdown2:not(:checked)+label:before {
position: fixed;
top: 0;
left: 0;
content: '';
width: 100%;
height: 100%;
z-index: -1;
cursor: auto;
pointer-events: none;
}
.dropdown:checked+label:before,
.dropdown1:checked+label:before,
.dropdown2:checked+label:before {
pointer-events: auto;
}
.dropdown:not(:checked)+label .uil,
.dropdown1:not(:checked)+label .uil,
.dropdown2:not(:checked)+label .uil {
content: '';
position: absolute;
right: 6px;
transform: rotate(0deg);
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
.dropdown:checked+label .uil,
.dropdown1:checked+label .uil,
.dropdown2:checked+label .uil {
content: '';
position: absolute;
right: 6px;
transform: rotate(180deg);
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
.dropdown:checked~.section-dropdown,
.dropdown1:checked~.section-dropdown1,
.dropdown2:checked~.section-dropdown2 {
opacity: 1;
pointer-events: auto;
transform: translateY(0);
}
/* .dropdown:checked+label,
.dropdown:not(:checked)+label:hover {
color: #000;
background-color: #FBBC05;
} */
.section-dropdown,
.section-dropdown1,
.section-dropdown2 {
position: absolute;
padding: 5px;
background-color: #004287;
top: 41px;
left: 0;
width: 100%;
border-radius: 4px;
display: block;
/* box-shadow: 0 14px 35px 0 rgba(9, 9, 12, 0.4); */
z-index: 2;
opacity: 0;
pointer-events: none;
transform: translateY(20px);
transition: all 200ms linear;
}
.section-dropdown:before,
.section-dropdown1:before,
.section-dropdown2:before {
position: absolute;
top: -20px;
left: 0;
width: 100%;
height: 20px;
content: '';
display: block;
z-index: 1;
}
.section-dropdown:after,
.section-dropdown1:after,
.section-dropdown2:after {
position: absolute;
top: -7px;
left: 30px;
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid #c82333;
content: '';
display: block;
z-index: 2;
transition: all 200ms linear;
}
.section-dropdown a,
.section-dropdown1 a,
.section-dropdown2 a {
position: relative;
color: #fff;
transition: all 200ms linear;
font-family: calibri, sans-serif;
font-weight: 500;
font-size: 14px;
border-radius: 2px;
padding: 5px 0;
padding-left: 20px;
padding-right: 15px;
margin: 2px 0;
text-align: left;
text-decoration: none;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
align-items: center;
justify-content: space-between;
-ms-flex-pack: distribute;
}
.section-dropdown a:hover,
.section-dropdown1 a:hover,
.section-dropdown2 a:hover {
color: #000;
background-color: #FBBC05;
}
.section-dropdown a .uil,
.section-dropdown1 a .uil,
.section-dropdown2 a .uil {
font-size: 22px;
}
.dropdown-sub:checked+label,
.dropdown-sub:not(:checked)+label,
.dropdown-sub1:checked+label,
.dropdown-sub1:not(:checked)+label,
.dropdown-sub2:checked+label,
.dropdown-sub2:not(:checked)+label {
position: relative;
color: #fff;
transition: all 200ms linear;
font-family: calibri, sans-serif;
font-weight: 500;
font-size: 14px;
border-radius: 2px;
padding: 5px 0;
padding-left: 20px;
padding-right: 15px;
text-align: left;
text-decoration: none;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
align-items: center;
justify-content: space-between;
-ms-flex-pack: distribute;
cursor: pointer;
}
.dropdown-sub:checked+label .uil,
.dropdown-sub:not(:checked)+label .uil,
.dropdown-sub1:checked+label .uil,
.dropdown-sub1:not(:checked)+label .uil,
.dropdown-sub2:checked+label .uil,
.dropdown-sub2:not(:checked)+label .uil {
font-size: 22px;
}
.dropdown-sub:not(:checked)+label .uil,
.dropdown-sub1:not(:checked)+label .uil,
.dropdown-sub2:not(:checked)+label .uil {
content: '';
position: absolute;
right: 6px;
transform: rotate(0deg);
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
.dropdown-sub:checked+label .uil,
.dropdown-sub1:checked+label .uil,
.dropdown-sub2:checked+label .uil {
content: '';
position: absolute;
right: 6px;
transform: rotate(180deg);
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
.dropdown-sub:checked+label:hover,
.dropdown-sub:not(:checked)+label:hover,
.dropdown-sub1:checked+label:hover,
.dropdown-sub1:not(:checked)+label:hover,
.dropdown-sub2:checked+label:hover,
.dropdown-sub2:not(:checked)+label:hover {
color: #000;
background-color: #FBBC05;
}
.section-dropdown-sub,
.section-dropdown-sub1,
.section-dropdown-sub2 {
position: relative;
display: block;
width: 100%;
pointer-events: none;
opacity: 0;
max-height: 0;
padding-left: 10px;
padding-right: 3px;
overflow: hidden;
transition: all 200ms linear;
}
.dropdown-sub:checked~.section-dropdown-sub,
.dropdown-sub1:checked~.section-dropdown-sub1,
.dropdown-sub2:checked~.section-dropdown-sub2 {
pointer-events: auto;
opacity: 1;
max-height: 999px;
}
.section-dropdown-sub a,
.section-dropdown-sub1 a,
.section-dropdown-sub2 a {
font-size: 14px;
}
.section-dropdown-sub a .uil,
.section-dropdown-sub1 a .uil,
.section-dropdown-sub2 a .uil {
font-size: 20px;
}
<div class="sec-center">
<input class="dropdown" type="checkbox" id="dropdown" name="dropdown" />
<label class="for-dropdown" for="dropdown">Train Services<i class="uil uil-arrow-down"></i></label>
<div class="section-dropdown">
Inside Dropdown Link 1 <i class="uil uil-arrow-right"></i>
<input class="dropdown-sub" type="checkbox" id="dropdown-sub" name="dropdown-sub" />
<label class="for-dropdown-sub" for="dropdown-sub">Dropdown Sub 1 <i class="uil uil-plus"></i></label>
<div class="section-dropdown-sub">
Dropdown Sub Link 1 <i class="uil uil-arrow-right"></i>
Dropdown Sub Link <i class="uil uil-arrow-right"></i>
</div>
Inside Dropdown Link 1 <i class="uil uil-arrow-right"></i>
Inside Dropdown Link 1 <i class="uil uil-arrow-right"></i>
</div>
</div>
<div class="sec-center1">
<input class="dropdown1" type="checkbox" id="dropdown1" name="dropdown1" />
<label class="for-dropdown1" for="dropdown1">Category<i class="uil uil-arrow-down"></i></label>
<div class="section-dropdown1">
Inside Dropdown Link 2 <i class="uil uil-arrow-right"></i>
<input class="dropdown-sub1" type="checkbox" id="dropdown-sub1" name="dropdown-sub1" />
<label class="for-dropdown-sub1" for="dropdown-sub1">Dropdown Sub 2 <i class="uil uil-plus"></i></label>
<div class="section-dropdown-sub1">
Dropdown Sub Link 2<i class="uil uil-arrow-right"></i>
Dropdown Sub Link <i class="uil uil-arrow-right"></i>
</div>
Inside Dropdown Link 2 <i class="uil uil-arrow-right"></i>
Inside Dropdown Link 3 <i class="uil uil-arrow-right"></i>
</div>
</div>
<div class="sec-center2">
<input class="dropdown2" type="checkbox" id="dropdown2" name="dropdown2" />
<label class="for-dropdown2" for="dropdown2">Author<i class="uil uil-arrow-down"></i></label>
<div class="section-dropdown2">
Inside Dropdown Link 2 <i class="uil uil-arrow-right"></i>
<input class="dropdown-sub2" type="checkbox" id="dropdown-sub2" name="dropdown-sub2" />
<label class="for-dropdown-sub2" for="dropdown-sub2">Dropdown Sub 2 <i class="uil uil-plus"></i></label>
<div class="section-dropdown-sub2">
Dropdown Sub Link 2<i class="uil uil-arrow-right"></i>
Dropdown Sub Link <i class="uil uil-arrow-right"></i>
</div>
Inside Dropdown Link 2 <i class="uil uil-arrow-right"></i>
Inside Dropdown Link 3 <i class="uil uil-arrow-right"></i>
</div>
</div>

Related

How to fix the Second dropdown which is not working?

I have created drop-down which is working properly but it's not closing when opening other. I need to close one when other is opened. It should be done through CSS only, no JS. So, I need a fix so all of them work independently. I have tried but couldn't do it. I am posting the HTML and CSS code below please have look. Please help me to fix it.
#import url('https://fonts.googleapis.com/css2?family=Roboto:wght#400;500;700;900&display=swap');
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
font-family: 'Roboto', sans-serif;
font-weight: 500;
font-size: 15px;
line-height: 1.4;
color: #fff;
background-color: #1f2029;
overflow-x: hidden;
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/1462889/pat-back.svg');
background-position: center;
background-repeat: repeat;
background-size: 4%;
width: 100%;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-pack: center;
justify-content: center;
padding-top: 100px;
padding-bottom: 300px;
}
.sec-center,
.sec-center1,
.sec-center2 {
position: relative;
max-width: 100%;
text-align: center;
z-index: 200;
display: inline-block;
margin-right: 5px;
}
[type="checkbox"]:checked,
[type="checkbox"]:not(:checked) {
position: absolute;
left: -9999px;
opacity: 0;
pointer-events: none;
}
.dropdown:checked+label,
.dropdown:not(:checked)+label,
.dropdown1:checked+label,
.dropdown1:not(:checked)+label,
.dropdown2:checked+label,
.dropdown2:not(:checked)+label {
position: relative;
font-family: calibri, sans-serif;
font-weight: 500;
font-size: 14px;
/* line-height: 2; */
/* height: 50px; */
transition: all 200ms linear;
/* border-radius: 4px; */
/* width: 220px; */
letter-spacing: 1px;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
align-items: center;
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
justify-content: center;
-ms-flex-pack: center;
text-align: center;
border: none;
background-color: transparent;
cursor: pointer;
color: #fff;
/* box-shadow: 0 12px 35px 0 rgb(255 235 167 / 15%); */
padding: 4px 20px;
border-right: 2px solid #fff;
border-radius: 50px;
}
.dropdown:checked+label:before,
.dropdown:not(:checked)+label:before,
.dropdown1:checked+label:before,
.dropdown1:not(:checked)+label:before,
.dropdown2:checked+label:before,
.dropdown2:not(:checked)+label:before {
position: fixed;
top: 0;
left: 0;
content: '';
width: 100%;
height: 100%;
z-index: -1;
cursor: auto;
pointer-events: none;
}
.dropdown:checked+label:before,
.dropdown1:checked+label:before,
.dropdown2:checked+label:before {
pointer-events: auto;
}
.dropdown:not(:checked)+label .uil,
.dropdown1:not(:checked)+label .uil,
.dropdown2:not(:checked)+label .uil {
content: '';
position: absolute;
right: 6px;
transform: rotate(0deg);
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
.dropdown:checked+label .uil,
.dropdown1:checked+label .uil,
.dropdown2:checked+label .uil {
content: '';
position: absolute;
right: 6px;
transform: rotate(180deg);
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
.dropdown:checked~.section-dropdown,
.dropdown1:checked~.section-dropdown1,
.dropdown2:checked~.section-dropdown2 {
opacity: 1;
pointer-events: auto;
transform: translateY(0);
}
/* .dropdown:checked+label,
.dropdown:not(:checked)+label:hover {
color: #000;
background-color: #FBBC05;
} */
.section-dropdown,
.section-dropdown1,
.section-dropdown2 {
position: absolute;
padding: 5px;
background-color: #004287;
top: 41px;
left: 0;
width: 100%;
border-radius: 4px;
display: block;
/* box-shadow: 0 14px 35px 0 rgba(9, 9, 12, 0.4); */
z-index: 2;
opacity: 0;
pointer-events: none;
transform: translateY(20px);
transition: all 200ms linear;
}
.section-dropdown:before,
.section-dropdown1:before,
.section-dropdown2:before {
position: absolute;
top: -20px;
left: 0;
width: 100%;
height: 20px;
content: '';
display: block;
z-index: 1;
}
.section-dropdown:after,
.section-dropdown1:after,
.section-dropdown2:after {
position: absolute;
top: -7px;
left: 30px;
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid #c82333;
content: '';
display: block;
z-index: 2;
transition: all 200ms linear;
}
.section-dropdown a,
.section-dropdown1 a,
.section-dropdown2 a {
position: relative;
color: #fff;
transition: all 200ms linear;
font-family: calibri, sans-serif;
font-weight: 500;
font-size: 14px;
border-radius: 2px;
padding: 5px 0;
padding-left: 20px;
padding-right: 15px;
margin: 2px 0;
text-align: left;
text-decoration: none;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
align-items: center;
justify-content: space-between;
-ms-flex-pack: distribute;
}
.section-dropdown a:hover,
.section-dropdown1 a:hover,
.section-dropdown2 a:hover {
color: #000;
background-color: #FBBC05;
}
.section-dropdown a .uil,
.section-dropdown1 a .uil,
.section-dropdown2 a .uil {
font-size: 22px;
}
.dropdown-sub:checked+label,
.dropdown-sub:not(:checked)+label,
.dropdown-sub1:checked+label,
.dropdown-sub1:not(:checked)+label,
.dropdown-sub2:checked+label,
.dropdown-sub2:not(:checked)+label {
position: relative;
color: #fff;
transition: all 200ms linear;
font-family: calibri, sans-serif;
font-weight: 500;
font-size: 14px;
border-radius: 2px;
padding: 5px 0;
padding-left: 20px;
padding-right: 15px;
text-align: left;
text-decoration: none;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
align-items: center;
justify-content: space-between;
-ms-flex-pack: distribute;
cursor: pointer;
}
.dropdown-sub:checked+label .uil,
.dropdown-sub:not(:checked)+label .uil,
.dropdown-sub1:checked+label .uil,
.dropdown-sub1:not(:checked)+label .uil,
.dropdown-sub2:checked+label .uil,
.dropdown-sub2:not(:checked)+label .uil {
font-size: 22px;
}
.dropdown-sub:not(:checked)+label .uil,
.dropdown-sub1:not(:checked)+label .uil,
.dropdown-sub2:not(:checked)+label .uil {
content: '';
position: absolute;
right: 6px;
transform: rotate(0deg);
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
.dropdown-sub:checked+label .uil,
.dropdown-sub1:checked+label .uil,
.dropdown-sub2:checked+label .uil {
content: '';
position: absolute;
right: 6px;
transform: rotate(180deg);
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid #fff;
}
.dropdown-sub:checked+label:hover,
.dropdown-sub:not(:checked)+label:hover,
.dropdown-sub1:checked+label:hover,
.dropdown-sub1:not(:checked)+label:hover,
.dropdown-sub2:checked+label:hover,
.dropdown-sub2:not(:checked)+label:hover {
color: #000;
background-color: #FBBC05;
}
.section-dropdown-sub,
.section-dropdown-sub1,
.section-dropdown-sub2 {
position: relative;
display: block;
width: 100%;
pointer-events: none;
opacity: 0;
max-height: 0;
padding-left: 10px;
padding-right: 3px;
overflow: hidden;
transition: all 200ms linear;
}
.dropdown-sub:checked~.section-dropdown-sub,
.dropdown-sub1:checked~.section-dropdown-sub1,
.dropdown-sub2:checked~.section-dropdown-sub2 {
pointer-events: auto;
opacity: 1;
max-height: 999px;
}
.section-dropdown-sub a,
.section-dropdown-sub1 a,
.section-dropdown-sub2 a {
font-size: 14px;
}
.section-dropdown-sub a .uil,
.section-dropdown-sub1 a .uil,
.section-dropdown-sub2 a .uil {
font-size: 20px;
}
<div class="sec-center">
<input class="dropdown" type="checkbox" id="dropdown" name="dropdown" />
<label class="for-dropdown" for="dropdown">Train Services<i class="uil uil-arrow-down"></i></label>
<div class="section-dropdown">
Inside Dropdown Link 1 <i class="uil uil-arrow-right"></i>
<input class="dropdown-sub" type="checkbox" id="dropdown-sub" name="dropdown-sub" />
<label class="for-dropdown-sub" for="dropdown-sub">Dropdown Sub 1 <i class="uil uil-plus"></i></label>
<div class="section-dropdown-sub">
Dropdown Sub Link 1 <i class="uil uil-arrow-right"></i>
Dropdown Sub Link <i class="uil uil-arrow-right"></i>
</div>
Inside Dropdown Link 1 <i class="uil uil-arrow-right"></i>
Inside Dropdown Link 1 <i class="uil uil-arrow-right"></i>
</div>
</div>
<div class="sec-center1">
<input class="dropdown1" type="checkbox" id="dropdown1" name="dropdown1" />
<label class="for-dropdown1" for="dropdown1">Category<i class="uil uil-arrow-down"></i></label>
<div class="section-dropdown1">
Inside Dropdown Link 2 <i class="uil uil-arrow-right"></i>
<input class="dropdown-sub1" type="checkbox" id="dropdown-sub1" name="dropdown-sub1" />
<label class="for-dropdown-sub1" for="dropdown-sub1">Dropdown Sub 2 <i class="uil uil-plus"></i></label>
<div class="section-dropdown-sub1">
Dropdown Sub Link 2<i class="uil uil-arrow-right"></i>
Dropdown Sub Link <i class="uil uil-arrow-right"></i>
</div>
Inside Dropdown Link 2 <i class="uil uil-arrow-right"></i>
Inside Dropdown Link 3 <i class="uil uil-arrow-right"></i>
</div>
</div>
<div class="sec-center2">
<input class="dropdown2" type="checkbox" id="dropdown2" name="dropdown2" />
<label class="for-dropdown2" for="dropdown2">Author<i class="uil uil-arrow-down"></i></label>
<div class="section-dropdown2">
Inside Dropdown Link 2 <i class="uil uil-arrow-right"></i>
<input class="dropdown-sub2" type="checkbox" id="dropdown-sub2" name="dropdown-sub2" />
<label class="for-dropdown-sub2" for="dropdown-sub2">Dropdown Sub 2 <i class="uil uil-plus"></i></label>
<div class="section-dropdown-sub2">
Dropdown Sub Link 2<i class="uil uil-arrow-right"></i>
Dropdown Sub Link <i class="uil uil-arrow-right"></i>
</div>
Inside Dropdown Link 2 <i class="uil uil-arrow-right"></i>
Inside Dropdown Link 3 <i class="uil uil-arrow-right"></i>
</div>
</div>
For the second dropdown you need to change the class names. Your first dropdown and second dropdown has exactly same class names, What this will do is you click on second dropdown, but you activate first. Also give CSS to each and every new class name you make.
To make both dropdown independent, you need to make sure they have unique identifiers. Check this example:
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropdown-content {
display: none;
position: absolute;
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown:hover .dropdown-content {
display: block;
}
<div class="dropdown">
<button class="dropbtn">Dropdown 1</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Dropdown 2</button>
<div class="dropdown-content">
Link 4
Link 5
Link 6
</div>
</div>
In this code, you can see that each dropdown has a unique parent container with the class 'dropdown' and each has its own unique class 'dropbtn'. 'dropdown-content' div contained the dropdown content.

Navbar content not displaying properly

Hello I'm trying to style my navbar and have everything aligned properly, but I'm not sure what is making my nav content display like this. Also, how can I remove the grey box next to my nav brand? I messed around with it on the inspect elements, but I don't know how to get rid of it. I have provided my code below. Thanks!
When bs css link isn't added (How I want to keep it):
When bs css link is added:
HTML:
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Dashboard UI </title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel="stylesheet" href="./style.css">
</head>
<body>
<!---Navbar--->
<header>
<nav class="navbar navbar-expand-lg navbar-light">
<div class="container-fluid">
<a style="font-size: 45px; color: #A388E7;" class="navbar-brand" href="#"><strong>StudioPick</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-curresnt="page" href="index.html">Home</a>
</li>
<li class="nav-item2">
<div class="action">
<div class="profile" onclick="menuToggle();">
<img src="./assets/avatar.jpg" />
</div>
<div class="menu">
<h3 id="profile-name"><strong>User Name</strong></h3>
<p class="text-muted" id="userType" style="position: relative; top: -20px; right: -60px; font-size: 12px !important">Studio</p>
<ul>
<li>
<img src="./assets/icons/user.png" />Dashboard
</li>
<li>
<img src="./assets/icons/edit.png" />Edit profile
</li>
<li>
<img src="./assets/icons/envelope.png" />Inbox
</li>
<li>
<img src="./assets/icons/settings.png" />Setting
</li>
<li><img src="./assets/icons/question.png" />Help</li>
<li>
<img src="./assets/icons/log-out.png" />Logout
</li>
</ul>
</div>
</div>
</li>
</ul>
</div>
</div>
</nav>
</header>
<!---Navbar--->
<main class="main">
<div class="responsive-wrapper">
<div class="main-header">
<h1>Settings</h1>
<div class="search">
<input type="text" placeholder="Search" />
<button type="submit">
<i class="ph-magnifying-glass-bold"></i>
</button>
</div>
</div>
<div class="horizontal-tabs">
My details
Profile
Password
Team
Plan
Billing
Email
Notifications
Integrations
API
</div>
<div class="content-header">
<div class="content-header-intro">
<h2>Intergrations and connected apps</h2>
<p>Supercharge your workflow and connect the tool you use every day.</p>
</div>
<div class="content-header-actions">
<a href="#" class="button">
<i class="ph-faders-bold"></i>
<span>Filters</span>
</a>
<a href="#" class="button">
<i class="ph-plus-bold"></i>
<span>Request integration</span>
</a>
</div>
</div>
<div class="content">
<div class="content-panel">
<div class="vertical-tabs">
View all
Developer tools
Communication
Productivity
Browser tools
Marketplace
</div>
</div>
<div class="content-main">
<div class="card-grid">
<article class="card">
<div class="card-header">
<div>
<span><img src="https://assets.codepen.io/285131/zeplin.svg" /></span>
<h3>Zeplin</h3>
</div>
<label class="toggle">
<input type="checkbox" checked>
<span></span>
</label>
</div>
<div class="card-body">
<p>Collaboration between designers and developers.</p>
</div>
<div class="card-footer">
View integration
</div>
</article>
<article class="card">
<div class="card-header">
<div>
<span><img src="https://assets.codepen.io/285131/github.svg" /></span>
<h3>GitHub</h3>
</div>
<label class="toggle">
<input type="checkbox" checked>
<span></span>
</label>
</div>
<div class="card-body">
<p>Link pull requests and automate workflows.</p>
</div>
<div class="card-footer">
View integration
</div>
</article>
<article class="card">
<div class="card-header">
<div>
<span><img src="https://assets.codepen.io/285131/figma.svg" /></span>
<h3>Figma</h3>
</div>
<label class="toggle">
<input type="checkbox" checked>
<span></span>
</label>
</div>
<div class="card-body">
<p>Embed file previews in projects.</p>
</div>
<div class="card-footer">
View integration
</div>
</article>
</div>
</div>
</div>
</div>
</main>
<!-- partial -->
<script src='https://unpkg.com/phosphor-icons'></script><script src="./script.js"></script>
<script>
function menuToggle() {
const toggleMenu = document.querySelector(".menu");
toggleMenu.classList.toggle("active");
}
</script>
<!----More Bootstrap--->
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
<!----More Bootstrap--->
</body>
</html>
CSS:
#import url("https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght#0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
:root {
--c-text-primary: #282a32;
--c-text-secondary: #686b87;
--c-text-action: #404089;
--c-accent-primary: #434ce8;
--c-border-primary: #eff1f6;
--c-background-primary: #ffffff;
--c-background-secondary: #fdfcff;
--c-background-tertiary: #ecf3fe;
--c-background-quaternary: #e9ecf4;
}
body {
line-height: 1.5;
min-height: 100vh;
font-family: "Be Vietnam Pro", sans-serif;
background-color: #E5E5E5 !important;
color: var(--c-text-primary);
}
:focus {
outline: 0;
}
.navbar-light {
background-color: #ffffff;
}
.navbar-nav{
justify-content: space-between;
}
.navbar-brand {
font-size: 45px;
color: #A388E7 !important;
font-weight: bolder;
padding-top: 0.3125rem;
padding-bottom: 0.3125rem;
margin-right: 1rem;
text-decoration: none;
white-space: nowrap;
}
.nav-item{
color: #686868 !important;
font-size: 20px;
position: relative;
right: -1675px !important;
}
.nav-item a {
display: block;
padding: 0.5rem 1rem;
color: #000000;
text-decoration: none;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out;
}
#alert{
position: relative;
right: -3px !important;
}
.action {
position: fixed;
top: 20px;
right: 30px;
}
.action .profile {
position: relative;
width: 60px;
height: 60px;
border-radius: 50%;
overflow: hidden;
cursor: pointer;
}
.action .profile img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.action .menu {
position: absolute;
top: 120px;
right: -10px;
padding: 10px 20px;
background: #fff;
width: 200px;
box-sizing: 0 5px 25px rgba(0, 0, 0, 0.1);
border-radius: 15px;
transition: 0.5s;
visibility: hidden;
opacity: 0;
}
.action .menu.active {
top: 80px;
visibility: visible;
opacity: 1;
}
.action .menu::before {
content: "";
position: absolute;
top: -5px;
right: 28px;
width: 20px;
height: 20px;
background: #fff;
transform: rotate(45deg);
}
*, ::after, ::before {
box-sizing: border-box;
}
.action .menu h3 {
width: 100%;
text-align: center;
font-size: 18px;
padding: 20px 0;
font-weight: 500;
color: #555;
line-height: 1.5em;
}
.action .menu h3 span {
font-size: 14px;
color: #cecece;
font-weight: 300;
}
.action .menu ul li {
list-style: none;
padding: 16px 0;
border-top: 1px solid rgba(0, 0, 0, 0.05);
display: flex;
align-items: center;
}
.action .menu ul li img {
max-width: 20px;
margin-right: 10px;
opacity: 0.5;
transition: 0.5s;
}
.action .menu ul li:hover img {
opacity: 1;
}
.action .menu ul li a {
display: inline-block;
text-decoration: none;
color: #555;
font-weight: 500;
transition: 0.5s;
}
.action .menu ul li:hover a {
color: #9370DB;
}
.responsive-wrapper {
width: 90%;
max-width: 1280px;
margin-left: auto;
margin-right: auto;
}
.button {
font: inherit;
color: inherit;
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0 1em;
height: 40px;
border-radius: 8px;
line-height: 1;
border: 2px solid var(--c-border-primary);
color: var(--c-text-action);
font-size: 0.875rem;
transition: 0.15s ease;
background-color: var(--c-background-primary);
}
.button i {
margin-right: 0.5rem;
font-size: 1.25em;
}
.button span {
font-weight: 500;
}
.button:hover, .button:focus {
border-color: var(--c-accent-primary);
color: var(--c-accent-primary);
}
.main {
padding-top: 3rem;
}
.main-header {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
}
.main-header h1 {
font-size: 1.75rem;
font-weight: 600;
line-height: 1.25;
}
#media (max-width: 550px) {
.main-header h1 {
margin-bottom: 1rem;
}
}
.search {
position: relative;
display: flex;
align-items: center;
width: 100%;
max-width: 340px;
}
.search input {
font: inherit;
color: inherit;
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0 1em 0 36px;
height: 40px;
border-radius: 8px;
border: 2px solid var(--c-border-primary);
color: var(--c-text-action);
font-size: 0.875rem;
transition: 0.15s ease;
width: 100%;
line-height: 1;
}
.search input::-moz-placeholder {
color: var(--c-text-action);
}
.search input:-ms-input-placeholder {
color: var(--c-text-action);
}
.search input::placeholder {
color: var(--c-text-action);
}
.search input:focus, .search input:hover {
border-color: var(--c-accent-primary);
}
.search button {
display: inline-flex;
align-items: center;
justify-content: center;
border: 0;
background-color: transparent;
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
font-size: 1.25em;
color: var(--c-text-action);
padding: 0;
height: 40px;
}
.horizontal-tabs {
margin-top: 1.5rem;
display: flex;
align-items: center;
overflow-x: auto;
}
#media (max-width: 1000px) {
.horizontal-tabs {
scrollbar-width: none;
position: relative;
}
.horizontal-tabs::-webkit-scrollbar {
display: none;
}
}
.horizontal-tabs a {
display: inline-flex;
flex-shrink: 0;
align-items: center;
height: 48px;
padding: 0 0.25rem;
font-weight: 500;
color: inherit;
border-bottom: 3px solid transparent;
text-decoration: none;
transition: 0.15s ease;
}
.horizontal-tabs a:hover, .horizontal-tabs a:focus, .horizontal-tabs a.active {
color: var(--c-accent-primary);
border-bottom-color: var(--c-accent-primary);
}
.horizontal-tabs a + * {
margin-left: 1rem;
}
.content-header {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
padding-top: 3rem;
margin-top: -1px;
border-top: 1px solid var(--c-border-primary);
}
.content-header-intro h2 {
font-size: 1.25rem;
font-weight: 600;
}
.content-header-intro p {
color: var(--c-text-secondary);
margin-top: 0.25rem;
font-size: 0.875rem;
margin-bottom: 1rem;
}
#media (min-width: 800px) {
.content-header-actions a:first-child {
display: none;
}
}
.content {
border-top: 1px solid var(--c-border-primary);
margin-top: 2rem;
display: flex;
align-items: flex-start;
}
.content-panel {
display: none;
max-width: 280px;
width: 25%;
padding: 2rem 1rem 2rem 0;
margin-right: 3rem;
}
#media (min-width: 800px) {
.content-panel {
display: block;
}
}
.vertical-tabs {
display: flex;
flex-direction: column;
}
.vertical-tabs a {
display: flex;
align-items: center;
padding: 0.75em 1em;
background-color: transparent;
border-radius: 8px;
text-decoration: none;
font-weight: 500;
color: var(--c-text-action);
transition: 0.15s ease;
}
.vertical-tabs a:hover, .vertical-tabs a:focus, .vertical-tabs a.active {
background-color: var(--c-background-tertiary);
color: var(--c-accent-primary);
}
.vertical-tabs a + * {
margin-top: 0.25rem;
}
.content-main {
padding-top: 2rem;
padding-bottom: 6rem;
flex-grow: 1;
}
.card-grid {
display: grid;
grid-template-columns: repeat(1, 1fr);
-moz-column-gap: 1.5rem;
column-gap: 1.5rem;
row-gap: 1.5rem;
}
#media (min-width: 600px) {
.card-grid {
grid-template-columns: repeat(2, 1fr);
}
}
#media (min-width: 1200px) {
.card-grid {
grid-template-columns: repeat(3, 1fr);
}
}
.card {
background-color: var(--c-background-primary);
box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.05), 0 5px 15px 0 rgba(0, 0, 0, 0.05);
border-radius: 8px;
overflow: hidden;
display: flex;
flex-direction: column;
}
.card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 1.5rem 1.25rem 1rem 1.25rem;
}
.card-header div {
display: flex;
align-items: center;
}
.card-header div span {
width: 40px;
height: 40px;
border-radius: 8px;
display: inline-flex;
align-items: center;
justify-content: center;
}
.card-header div span img {
max-height: 100%;
}
.card-header div h3 {
margin-left: 0.75rem;
font-weight: 500;
}
.toggle span {
display: block;
width: 40px;
height: 24px;
border-radius: 99em;
background-color: var(--c-background-quaternary);
box-shadow: inset 1px 1px 1px 0 rgba(0, 0, 0, 0.05);
position: relative;
transition: 0.15s ease;
}
.toggle span:before {
content: "";
display: block;
position: absolute;
left: 3px;
top: 3px;
height: 18px;
width: 18px;
background-color: var(--c-background-primary);
border-radius: 50%;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.15);
transition: 0.15s ease;
}
.toggle input {
clip: rect(0 0 0 0);
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
.toggle input:checked + span {
background-color: var(--c-accent-primary);
}
.toggle input:checked + span:before {
transform: translateX(calc(100% - 2px));
}
.toggle input:focus + span {
box-shadow: 0 0 0 4px var(--c-background-tertiary);
}
.card-body {
padding: 1rem 1.25rem;
font-size: 0.875rem;
}
.card-footer {
margin-top: auto;
padding: 1rem 1.25rem;
display: flex;
align-items: center;
justify-content: flex-end;
border-top: 1px solid rgba(0,0,0,.125);
}
.card-footer a {
color: var(--c-text-action);
text-decoration: none;
font-weight: 500;
font-size: 0.875rem;
}
html::-webkit-scrollbar {
width: 12px;
}
html::-webkit-scrollbar-thumb {
background-color: var(--c-text-primary);
border: 4px solid var(--c-background-primary);
border-radius: 99em;
}
You are using Bootstrap 5, yet you did not linked it in the head:
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
Then change the structure of your Navbar:
<!---Navbar--->
<header>
<div class="navbar navbar-expand-md">
<div class="container">
Logo Here
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainmenu">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="mainmenu">
<ul class="navbar-nav ms-auto">
<li class="nav-item">Home</li>
<li class="nav-item">Page</li>
<li class="nav-item dropdown">
Dropdown
<ul class="dropdown-menu">
<li>Dropdown 01</li>
<li>Dropdown 02</li>
</ul>
</li>
<li class="nav-item">Contact</li>
</ul>
</div>
</div>
</div>
</header>
<!---Navbar--->
And finally, remove the custom CSS you made in your CSS file. Eventually, in the css file, search for Nav and delete everything related to the navbar

<nav> HTML tag shows different in Mozilla than in other browser

I'm not a front-end developer in fact I've basically copy-pasted an open-source nav bar and pasted it on my project editing the colors and id tags.
For some reason on Chrome, Edge, Opera the nav bar works perfectly while in Mozilla looks very buggy (see screenshot as I don't know how to describe it - left looks ok, right looks buggy) and I do not know why. Below is my code (don't mind the Django code injected) :
HTML
<nav id="main_nav" class="sidebar close"> <!-- cloe class to keep it close -->
<header>
<div class="image-text">
<span class="image">
<img src="logo.png" alt="">
</span>
<div class="text logo-text">
<span class="name">The Groove Cartel</span>
<span class="profession">Playlist Manager</span>
</div>
</div>
<i class='bx bx-chevron-right toggle'></i>
</header>
<div class="menu-bar">
<div class="menu">
<ul class="menu-links">
<li class="nav-link">
<a href="/">
<i class='bx bx-home-alt icon' ></i>
<span class="text nav-text">Home</span>
</a>
</li>
</ul>
</div>
<div class="bottom-content">
{% if user.is_authenticated %}
<li class="">
<a href="{% url 'account' user.username%}">
<i class='bx bxs-user-detail icon' ></i>
<span class="text nav-text">My profile</span>
</a>
</li>
{% endif %}
<li class="mode">
<div class="sun-moon">
<i class='bx bx-moon icon moon'></i>
<i class='bx bx-sun icon sun'></i>
</div>
<span class="mode-text text">Dark mode</span>
<div class="toggle-switch">
<span class="switch"></span>
</div>
</li>
</div>
</div>
</nav>
CSS
/* ===== Sidebar ===== */
.sidebar{
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 280px;
padding: 10px 14px;
background: var(--sidebar-color);
transition: var(--tran-05);
z-index: 100;
}
.sidebar.close{
width: 88px;
}
/* ===== Reusable code - Here ===== */
.menu-links{
padding-left: 0px !important;
}
.sidebar li{
height: 50px;
list-style: none;
display: flex;
align-items: center;
margin-top: 10px;
padding: 0px !important;
}
.sidebar header .image,
.sidebar .icon{
min-width: 60px;
border-radius: 6px;
}
.sidebar .icon{
min-width: 60px;
border-radius: 6px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
}
.sidebar .text,
.sidebar .icon{
color: var(--text-color);
transition: var(--tran-03);
}
.sidebar .text{
font-size: 17px;
font-family: Poppins-Medium;
white-space: nowrap;
opacity: 1;
}
.sidebar.close .text{
opacity: 0;
}
/* =========================== */
.sidebar header{
position: relative;
}
.sidebar header .image-text{
display: flex;
align-items: center;
}
.sidebar header .logo-text{
display: flex;
flex-direction: column;
}
header .image-text .name {
margin-top: 2px;
font-size: 18px;
font-family: Poppins-SemiBold;
}
header .image-text .profession{
font-size: 16px;
margin-top: -2px;
display: block;
}
.sidebar header .image{
display: flex;
align-items: center;
justify-content: center;
}
.sidebar header .image img{
width: 40px;
border-radius: 6px;
}
.sidebar header .toggle{
position: absolute;
top: 50%;
right: -25px;
transform: translateY(-50%) rotate(180deg);
height: 25px;
width: 25px;
background-color: var(--primary-color);
color: var(--sidebar-color);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
cursor: pointer;
transition: var(--tran-05);
}
body.dark .sidebar header .toggle{
color: var(--text-color);
}
.sidebar.close .toggle{
transform: translateY(-50%) rotate(0deg);
}
.sidebar .menu{
margin-top: 40px;
}
.sidebar li.search-box{
border-radius: 6px;
background-color: var(--primary-color-light);
cursor: pointer;
transition: var(--tran-05);
}
.sidebar li.search-box input{
height: 100%;
width: 100%;
outline: none;
border: none;
background-color: var(--primary-color-light);
color: var(--text-color);
border-radius: 6px;
font-size: 17px;
font-family: Poppins-Medium;
transition: var(--tran-05);
}
.sidebar li a{
list-style: none;
height: 100%;
background-color: transparent;
display: flex;
align-items: center;
height: 100%;
width: 100%;
border-radius: 6px;
text-decoration: none;
transition: var(--tran-03);
}
.sidebar li a:hover{
background-color: var(--primary-color);
}
.sidebar li a:hover .icon,
.sidebar li a:hover .text{
color: var(--sidebar-color);
}
body.dark .sidebar li a:hover .icon,
body.dark .sidebar li a:hover .text{
color: var(--text-color);
}
.sidebar .menu-bar{
height: calc(100% - 55px);
display: flex;
flex-direction: column;
justify-content: space-between;
overflow-y: scroll;
}
.menu-bar::-webkit-scrollbar{
display: none;
}
.sidebar .menu-bar .mode{
border-radius: 6px;
background-color: var(--primary-color-light);
position: relative;
transition: var(--tran-05);
}
.menu-bar .mode .sun-moon{
height: 50px;
width: 60px;
}
.mode .sun-moon i{
position: absolute;
}
.mode .sun-moon i.sun{
opacity: 0;
}
body.dark .mode .sun-moon i.sun{
opacity: 1;
}
body.dark .mode .sun-moon i.moon{
opacity: 0;
}
.menu-bar .bottom-content .toggle-switch{
position: absolute;
right: 0;
height: 100%;
min-width: 60px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 6px;
cursor: pointer;
}
.toggle-switch .switch{
position: relative;
height: 22px;
width: 40px;
border-radius: 25px;
background-color: var(--toggle-color);
transition: var(--tran-05);
}
.switch::before{
content: '';
position: absolute;
height: 15px;
width: 15px;
border-radius: 50%;
top: 50%;
left: 5px;
transform: translateY(-50%);
background-color: var(--sidebar-color);
transition: var(--tran-04);
}
body.dark .switch::before{
left: 20px;
}
.home{
position: absolute;
top: 0;
top: 0;
left: 280px;
height: 100vh;
width: calc(100% - 280px);
background-color: var(--body-color);
transition: var(--tran-05);
}
.home .text{
font-size: 30px;
font-family: Poppins-Medium;
color: var(--text-color);
padding: 12px 60px;
}
.sidebar.close ~ .home{
left: 78px;
height: 100vh;
width: calc(100% - 78px);
}
body.dark .home .text{
color: var(--text-color);
}

input [type=file] text uploding file, i am faccing uploaded file displaying issue

The below code i try for making upload file through local browser but it is only open browser which file is getting upload it is not displaying. please help where i am doing mistake.
.card {
position: relative;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
}
.md-form {
position: relative;
margin-top: 1.5rem;
margin-bottom: 1.5rem;
}
.file-field {
position: relative;
}
.btn-floating {
box-shadow: 0 5px 11px 0 rgba(0,0,0,.18), 0 4px 15px 0 rgba(0,0,0,.15);
position: relative;
z-index: 1;
vertical-align: middle;
display: inline-block;
overflow: hidden;
transition: all .2s ease-in-out;
margin: 10px;
border-radius: 50%;
padding: 0;
cursor: pointer;
width: 47px;
height: 47px;
}
.waves-effect {
position: relative;
cursor: pointer;
overflow: hidden;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.mt-0, .my-0 {
margin-top: 0!important;
}
.peach-gradient {
background: linear-gradient(40deg,#ffd86f,#fc6262,#ffd86f)!important;
}
.float-left {
float: left!important;
}
.btn-floating i {
display: inline-block;
width: inherit;
text-align: center;
color: #fff;
}
.btn-floating i {
font-size: 1.25rem;
line-height: 47px;
}
.file-field .file-path-wrapper {
overflow: hidden;
padding-left: 10px;
height: 2.5rem;
}
form input[type=text]:not(.browser-default), .md-form input[type=time]:not(.browser-default), .md-form input[type=url]:not(.browser-default), .md-form textarea.md-textarea {
box-sizing: content-box;
background-color: transparent;
border: none;
border-bottom: 1px solid #ced4da;
border-radius: 0;
outline: 0;
box-shadow: none;
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.file-field input[type=file] {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
width: 100%;
margin: 0;
padding: 0;
cursor: pointer;
opacity: 0;
}
<!DOCTYPE HTML>
<html>
<head><title>File Upload with Material Design</title>
</head>
<body>
<!--Card-->
<!--/.Card-->
<!--Card-->
<div class="card" style="width: 400px; margin: 40px; padding: 30px; background-color: #b1bace;">
<!--<img class="card-img-top" src="../images/instruction.jpg" alt="Card image cap">-->
<div class="card-body" style="margin-bottom: 20px; ">
<h2 class="card-title" style="color: #fff;">Card title</h2>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<form class="md-form" class="mb-3">
<div class="file-field">
<a class="btn-floating peach-gradient mt-0 float-left">
<i class="fa fa-upload" aria-hidden="true"></i>
<input type="file">
</a>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Upload your file">
</div>
</div>
</form>
</div>
</body>
</html>
The above code i try for making upload file through local browser but it is only open browser which file is getting upload it is not displaying. please help where i am doing mistake.
Hope it helps.
$('#trigger').change(function(e){
var fileName = e.target.files[0].name;
$('#placeholder').attr("placeholder", fileName);
});
.card {
position: relative;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
}
.md-form {
position: relative;
margin-top: 1.5rem;
margin-bottom: 1.5rem;
}
.file-field {
position: relative;
}
.btn-floating {
box-shadow: 0 5px 11px 0 rgba(0,0,0,.18), 0 4px 15px 0 rgba(0,0,0,.15);
position: relative;
z-index: 1;
vertical-align: middle;
display: inline-block;
overflow: hidden;
transition: all .2s ease-in-out;
margin: 10px;
border-radius: 50%;
padding: 0;
cursor: pointer;
width: 47px;
height: 47px;
}
.waves-effect {
position: relative;
cursor: pointer;
overflow: hidden;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.mt-0, .my-0 {
margin-top: 0!important;
}
.peach-gradient {
background: linear-gradient(40deg,#ffd86f,#fc6262,#ffd86f)!important;
}
.float-left {
float: left!important;
}
.btn-floating i {
display: inline-block;
width: inherit;
text-align: center;
color: #fff;
}
.btn-floating i {
font-size: 1.25rem;
line-height: 47px;
}
.file-field .file-path-wrapper {
overflow: hidden;
padding-left: 10px;
height: 2.5rem;
}
form input[type=text]:not(.browser-default), .md-form input[type=time]:not(.browser-default), .md-form input[type=url]:not(.browser-default), .md-form textarea.md-textarea {
box-sizing: content-box;
background-color: transparent;
border: none;
border-bottom: 1px solid #ced4da;
border-radius: 0;
outline: 0;
box-shadow: none;
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.file-field input[type=file] {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
width: 100%;
margin: 0;
padding: 0;
cursor: pointer;
opacity: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE HTML>
<html>
<head><title>File Upload with Material Design</title>
</head>
<body>
<!--Card-->
<!--/.Card-->
<!--Card-->
<div class="card" style="width: 400px; margin: 40px; padding: 30px; background-color: #b1bace;">
<!--<img class="card-img-top" src="../images/instruction.jpg" alt="Card image cap">-->
<div class="card-body" style="margin-bottom: 20px; ">
<h2 class="card-title" style="color: #fff;">Card title</h2>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<form class="md-form" class="mb-3">
<div class="file-field">
<a class="btn-floating peach-gradient mt-0 float-left">
<i class="fa fa-upload" aria-hidden="true"></i>
<input type="file" id="trigger">
</a>
<div class="file-path-wrapper">
<input id="placeholder" class="file-path validate" type="text" placeholder="Upload your file">
</div>
</div>
</form>
</div>
</body>
</html>

Adding Dropdown to Side Navigation Menu

Editing and adding code to snippet .This is the full code extraced from the below two links.
body {
font-family: 'Alegreya Sans', sans-serif;
overflow-x: hidden;
background: gray;
color: white;
}
#content {
padding: 15px;
transition: margin-left 0.7s;
overflow: hidden;
width: 100%;
}
.slide a {
color: #000;
font-size: 36px;
}
.nav .close {
position: absolute;
top: 8px;
right: 22px;
margin-left: 50px;
font-size: 30px;
color: #ccc;
}
.nav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #282828;
overflow-x: hidden;
padding-top: 60px;
transition: 0.7s;
}
.nav a.item {
display: flex;
flex-direction: row;
padding: 18px 30px;
font-size: 30px;
text-decoration: none;
color: #ccc;
background-color: #3d3d3d;
border-top: 1px solid #ccc;
}
.nav .last {
border-bottom: 1px solid #ccc;
}
.nav a.item:hover {
color: #fff;
background-color: #cf0000;
transition: 0.4s;
}
.nav .icon {
padding-right: 10px;
font-size: 35px;
}
.nav ul {
display: flex;
position: absolute;
width: 100%;
margin-top: 50px;
}
.nav ul li {
list-style: none;
}
.nav ul li a.inline {
font-size: 26px;
color: #ccc;
padding: 6px 5px 3px;
}
.nav ul li a.inline:hover {
color: #cf0000;
}
.content p{
font-size: 18px;
text-align: center;
margin-left: 310px;
}
.footer-home{
position: fixed;
left: 0;
bottom: 0;
width:100%;
height: auto;
background-color:#282828;
color: white;
padding: 10px;
text-align: center;
}
* {
box-sizing: border-box;
}
.column {
float: left;
width: 33.33%;
padding: 5px;
}
/* Clearfix (clear floats) */
.row::after {
content: "";
clear: both;
display: table;
}
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<script src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script>
<link rel="stylesheet" href="style.css">
<script>
function openSlideMenu(){
document.getElementById('menu').style.width = '250px';
document.getElementById('content').style.marginLeft = '250px';
}
function closeSlideMenu(){
document.getElementById('menu').style.width = '0';
document.getElementById('content').style.marginLeft = '0';
}
</script>
</head>
<body>
<div id="content">
<span class="slide">
<a href="#" onclick="openSlideMenu()">
<i class="fas fa-bars"></i>
</a>
</span>
<div id="menu" class="nav">
<a href="#" class="close" onclick="closeSlideMenu()">
<i class="fas fa-times"></i>
</a>
<img src="#" alt="" width="150" height="100">
<i class="fas fa-home icon"></i>Home
<i class="fas fa-desktop icon"></i>Dashboards
<i class="fas fa-map-marker icon"></i>Engagements
<i class="fab fa-wpforms icon"></i>Contact
<ul>
Can't get dropdown to work.
Tried several ways to make dropdown active.
html - http://textsnip.com/nau26f
css - http://textsnip.com/dyk75z
Trying to make dropdown active when hovering over dashboards. Any help would be greatly appreciated.
Here's my solution
function openSlideMenu(){
document.getElementById('menu').style.width = '250px';
document.getElementById('content').style.marginLeft = '250px';
}
function closeSlideMenu(){
document.getElementById('menu').style.width = '0';
document.getElementById('content').style.marginLeft = '0';
}
body {
font-family: 'Alegreya Sans', sans-serif;
overflow-x: hidden;
background: gray;
color: white;
}
#content {
padding: 15px;
transition: margin-left 0.7s;
overflow: hidden;
width: 100%;
}
.slide a {
color: #000;
font-size: 36px;
}
.nav .close {
position: absolute;
top: 8px;
right: 22px;
margin-left: 50px;
font-size: 30px;
color: #ccc;
}
.nav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #282828;
overflow-x: hidden;
padding-top: 60px;
transition: 0.7s;
}
.nav a.item {
display: flex;
flex-direction: row;
padding: 18px 30px;
font-size: 30px;
text-decoration: none;
color: #ccc;
background-color: #3d3d3d;
border-top: 1px solid #ccc;
}
.nav .last {
border-bottom: 1px solid #ccc;
}
.nav a.item:hover {
color: #fff;
background-color: #cf0000;
transition: 0.4s;
}
.nav .icon {
padding-right: 10px;
font-size: 35px;
}
.nav ul {
display: flex;
position: absolute;
width: 100%;
margin-top: 50px;
}
.nav ul li {
list-style: none;
}
.nav ul li a.inline {
font-size: 26px;
color: #ccc;
padding: 6px 5px 3px;
}
.nav ul li a.inline:hover {
color: #cf0000;
}
.content p{
font-size: 18px;
text-align: center;
margin-left: 310px;
}
.footer-home{
position: fixed;
left: 0;
bottom: 0;
width:100%;
height: auto;
background-color:#282828;
color: white;
padding: 10px;
text-align: center;
}
* {
box-sizing: border-box;
}
.column {
float: left;
width: 33.33%;
padding: 5px;
}
/* Clearfix (clear floats) */
.row::after {
content: "";
clear: both;
display: table;
}
.dropbtn {
display: flex;
flex-direction: row;
padding: 18px 30px;
font-size: 30px;
text-decoration: none;
color: #ccc;
background-color: #3d3d3d;
border-top: 1px solid #ccc;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
width: 100%;
}
.dropdown-content a {
display: flex;
width: 100%;
flex-direction: row;
padding: 18px 30px;
font-size: 30px;
text-decoration: none;
color: #ccc;
background-color: #3d3d3d;
border-top: 1px solid #ccc;
}
.dropdown-content a:hover {background-color: #cf0000;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #cf0000;}
<script src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script>
<div id="content">
<span class="slide">
<a href="#" onclick="openSlideMenu()">
<i class="fas fa-bars"></i>
</a>
</span>
<div id="menu" class="nav">
<a href="#" class="close" onclick="closeSlideMenu()">
<i class="fas fa-times"></i>
</a>
<img src="#" alt="" width="150" height="100">
<i class="fas fa-home icon"></i>Home
<div class="dropdown">
<a class="dropbtn">
<i class="fas fa-desktop icon"></i>
Dashboards
</a>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
<a href="maps.html" class="item">
<i class="fas fa-map-marker icon"></i>
Engagements
</a>
<a href="contact.html" class="item last">
<i class="fab fa-wpforms icon"></i>
Contact
</a>
</div>
</div>