Checkbox burger menu covering body content - html

I'm having a problem with my checkbox burger menu dropdown is covering content when clicked. It may also look like the menu itself isn't "connected" to the navbar when clicked.
I have tried changing position to absolute but that creates a hidden problem I can't solve.
My first stackoverflow, and one of my first projects. Thanks for patience and help :)
https://jsfiddle.net/ow82jhbm/1/
#media only screen and (max-width:1111px) {
#navtekst {
display: none;
}
}
#sidebarMenu {
height: auto;
/*change here related your menu height*/
position: fixed;
overflow: auto;
width: 100%;
z-index: 100;
transform: translateY(-171px);
/*change here related your menu height*/
}
.main-content-wrapper a {
width: 100%;
height: 40px;
display: block;
text-align: center;
font-size: 20px;
padding-top: 10px;
padding-bottom: 10px;
border: 0.5px solid white;
color: whitesmoke;
text-decoration: none;
}
.sidebarMenuInner {
margin: 0;
padding: 0;
border-top: 1px solid rgba(255, 255, 255, 0.10);
}
input[type="checkbox"]:checked~#sidebarMenu {
transform: translatey(0);
top: 50px/*change here related your top menu height*/
}
input[type=checkbox] {
transition: all 0.3s;
box-sizing: border-box;
display: none;
}
.sidebarIconToggle {
transition: all 0.3s;
box-sizing: border-box;
cursor: pointer;
position: absolute;
z-index: 99;
height: 22px;
width: 22px;
right: 20px;
top: 20px;
display: none
}
/*Whole spinner*/
.spinner {
transition: all 0.3s;
box-sizing: border-box;
position: absolute;
height: 3.5px;
width: 100%;
background-color: white;
}
/*Each line in spinner*/
.horizontal {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
.diagonal.part-1 {
position: relative;
transition: all 0.3s;
box-sizing: border-box;
float: left;
}
.diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
/*Spinner rotation*/
input[type=checkbox]:checked~.sidebarIconToggle>.horizontal {
transition: all 0.3s;
box-sizing: border-box;
opacity: 0;
}
input[type=checkbox]:checked~.sidebarIconToggle>.diagonal.part-1 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(135deg);
margin-top: 8px;
}
input[type=checkbox]:checked~.sidebarIconToggle>.diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(-135deg);
margin-top: -9px;
}
#media screen and (max-width: 1111px) {
.sidebarIconToggle {
display: block
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark text-white">
<!--Brand/logo-->
<a class="navbar-brand">
<img id="logo" alt="Logo" src="TradeLeague-1 (7).png" />
</a>
<!--Links-->
<ul class="navbar-nav" [class.is-open]="isMenuOpen" style="font-size:18px" id="navtekst">
<!--Homepage-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/home"> Home</a>
</li>
<!--Create company-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/createcompany"> Create Company</a>
</li>
<!--Company list-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/companies"> Companies</a>
</li>
<!--Leaderboard-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/leaderboard"> Leaderboard</a>
</li>
</ul>
<!--Creating a new list aligned to the right-->
<ul class="navbar-nav ml-auto" style="font-size:18px" id="navtekst">
<!--Log-in Page-->
<li class="nav-item ">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/login"> Sign-in</a>
</li>
<!--Profilepage-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/profile"><i class="fa fa-user-circle"></i> Profile</a>
</li>
</ul>
<input type="checkbox" class="openSidebarMenu ml-auto" id="openSidebarMenu">
<label for="openSidebarMenu" class="sidebarIconToggle">
<div class="spinner diagonal part-1"></div>
<div class="spinner horizontal"></div>
<div class="spinner diagonal part-2"></div>
</label>
<div id="sidebarMenu" class="bg-dark">
<div class="main-content-wrapper">
<a class="nav-link" routerLinkActive="active" routerLink="/home"> Home</a>
<a class="nav-link" routerLinkActive="active" routerLink="/createuser"> Create User</a>
<a class="nav-link" routerLinkActive="active" routerLink="/createcompany"> Create Company</a>
<a class="nav-link" routerLinkActive="active" routerLink="/companies"> Companies</a>
<a class="nav-link" routerLinkActive="active" routerLink="/leaderboard"> Leaderboard</a>
<a class="nav-link" routerLinkActive="active" routerLink="/login"> Sign in</a>
<a class="nav-link" routerLinkActive="active" routerLink="/profile"> Profile</a>
</div>
</div>
</nav>
<br/>
<!--HTML EXAMPLE*/-->
<div class="container bg-dark card text-white" style="text-align: center; width: 65%">
<br />
<!--Header-->
<h1><u>Create User</u></h1>
<br />
<!--Form for creating new user-->
<form [formGroup]="skjema" (ngSubmit)="onSubmit()">
<div class="form-group">
<label>Username</label>
<input class="form-control" formControlName="username" />
<p class="alert alert-warning" [hidden]="skjema.controls.username.valid || (skjema.controls.username.pristine && !submitted)">
Username er obligatorisk.
</p>
</div>
<div class="form-group">
<label>Password</label>
<input class="form-control" formControlName="password" />
<p class="alert alert-warning" [hidden]="skjema.controls.password.valid || (skjema.controls.password.pristine && !submitted)">
Password er obligatorisk.
</p>
</div>
<!--Sends company to script with function createUser() when confirm button is pressed-->
<div class="form-group">
<button type="submit" style="margin-right:15px" [disabled]="!skjema.valid" class="btn btn-primary">Registrer</button>
<button class="btn btn-primary" routerLink="/">Tilbake</button>
</div>
</form>
</div>

Typically, this is done using JS and targets the same menu instead of using two.
With your current structure, you can make this work by first changing #sidebarMenu to position: absolute;. Then target input[type="checkbox"]:checked~#sidebarMenu and use top: 100%; to make sure your menu is appearing directly below the navbar. Make sure you remove the translateY value in those styles.
Next, to get the dropdown menu to push down the other content you will have to use position: relative; on input[type="checkbox"]:checked~#sidebarMenu. This enables the menu to push down and extend the actual navbar height. I used flex to re-configure the alignment of your nav on mobile.
#media only screen and (max-width:1111px) {
#navtekst {
display: none;
}
}
#sidebarMenu {
height: auto;
/*change here related your menu height*/
position: absolute;
display: none;
width: 100%;
z-index: 100;
transform: translateY(-171px);
/*change here related your menu height*/
}
.main-content-wrapper a {
width: 100%;
height: 40px;
display: block;
text-align: center;
font-size: 20px;
padding-top: 10px;
padding-bottom: 10px;
border: 0.5px solid white;
color: whitesmoke;
text-decoration: none;
}
.sidebarMenuInner {
margin: 0;
padding: 0;
border-top: 1px solid rgba(255, 255, 255, 0.10);
}
input[type="checkbox"]:checked~#sidebarMenu {
transform: translatey(0);
position: relative;
top: 100%/*change here related your top menu height*/
;
left: 0;
display: block;
padding-top: 1em;
}
input[type=checkbox] {
transition: all 0.3s;
box-sizing: border-box;
display: none;
}
.sidebarIconToggle {
transition: all 0.3s;
box-sizing: border-box;
cursor: pointer;
position: absolute;
z-index: 99;
height: 22px;
width: 22px;
right: 20px;
top: 20px;
display: none
}
/*Whole spinner*/
.spinner {
transition: all 0.3s;
box-sizing: border-box;
position: absolute;
height: 3.5px;
width: 100%;
background-color: white;
}
/*Each line in spinner*/
.horizontal {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
.diagonal.part-1 {
position: relative;
transition: all 0.3s;
box-sizing: border-box;
float: left;
}
.diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
/*Spinner rotation*/
input[type=checkbox]:checked~.sidebarIconToggle>.horizontal {
transition: all 0.3s;
box-sizing: border-box;
opacity: 0;
}
input[type=checkbox]:checked~.sidebarIconToggle>.diagonal.part-1 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(135deg);
margin-top: 8px;
}
input[type=checkbox]:checked~.sidebarIconToggle>.diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(-135deg);
margin-top: -9px;
}
#media screen and (max-width: 1111px) {
.sidebarIconToggle {
display: block
}
.navbar {
flex-flow: column !important;
}
.navbar-brand {
width: 99%;
}
}
#media only screen and (min-width: 1111px) {
#sidebarMenu {
display: none !important;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark text-white">
<!--Brand/logo-->
<a class="navbar-brand">
<img id="logo" alt="Logo" src="TradeLeague-1 (7).png" />
</a>
<!--Links-->
<ul class="navbar-nav" [class.is-open]="isMenuOpen" style="font-size:18px" id="navtekst">
<!--Homepage-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/home"> Home</a>
</li>
<!--Create company-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/createcompany"> Create Company</a>
</li>
<!--Company list-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/companies"> Companies</a>
</li>
<!--Leaderboard-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/leaderboard"> Leaderboard</a>
</li>
</ul>
<!--Creating a new list aligned to the right-->
<ul class="navbar-nav ml-auto" style="font-size:18px" id="navtekst">
<!--Log-in Page-->
<li class="nav-item ">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/login"> Sign-in</a>
</li>
<!--Profilepage-->
<li class="nav-item">
<!--Routering and displaying active page-->
<a class="nav-link" routerLinkActive="active" routerLink="/profile"><i class="fa fa-user-circle"></i> Profile</a>
</li>
</ul>
<input type="checkbox" class="openSidebarMenu ml-auto" id="openSidebarMenu">
<label for="openSidebarMenu" class="sidebarIconToggle">
<div class="spinner diagonal part-1"></div>
<div class="spinner horizontal"></div>
<div class="spinner diagonal part-2"></div>
</label>
<div id="sidebarMenu" class="bg-dark">
<div class="main-content-wrapper">
<a class="nav-link" routerLinkActive="active" routerLink="/home"> Home</a>
<a class="nav-link" routerLinkActive="active" routerLink="/createuser"> Create User</a>
<a class="nav-link" routerLinkActive="active" routerLink="/createcompany"> Create Company</a>
<a class="nav-link" routerLinkActive="active" routerLink="/companies"> Companies</a>
<a class="nav-link" routerLinkActive="active" routerLink="/leaderboard"> Leaderboard</a>
<a class="nav-link" routerLinkActive="active" routerLink="/login"> Sign in</a>
<a class="nav-link" routerLinkActive="active" routerLink="/profile"> Profile</a>
</div>
</div>
</nav>
<br/>
<!--HTML EXAMPLE*/-->
<div class="container bg-dark card text-white" style="text-align: center; width: 65%">
<br />
<!--Header-->
<h1><u>Create User</u></h1>
<br />
<!--Form for creating new user-->
<form [formGroup]="skjema" (ngSubmit)="onSubmit()">
<div class="form-group">
<label>Username</label>
<input class="form-control" formControlName="username" />
<p class="alert alert-warning" [hidden]="skjema.controls.username.valid || (skjema.controls.username.pristine && !submitted)">
Username er obligatorisk.
</p>
</div>
<div class="form-group">
<label>Password</label>
<input class="form-control" formControlName="password" />
<p class="alert alert-warning" [hidden]="skjema.controls.password.valid || (skjema.controls.password.pristine && !submitted)">
Password er obligatorisk.
</p>
</div>
<!--Sends company to script with function createUser() when confirm button is pressed-->
<div class="form-group">
<button type="submit" style="margin-right:15px" [disabled]="!skjema.valid" class="btn btn-primary">Registrer</button>
<button class="btn btn-primary" routerLink="/">Tilbake</button>
</div>
</form>
</div>

Related

Isolating topbar css style from sidebar css style code

I have a topbar that works well on all page, and I'm trying to add a sidebar as well, but the style of the topbar is applied to the sidebar instead of using the rest of the code.
How can I isolate topbar css style code portion from the sidebar style css code portion?
index.html
<!DOCTYPE html>
<html lang="en">
<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">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
<link rel="stylesheet" href="/static/css/styles.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" >
<title>
{% block title %} {% endblock title %}
</title>
</head>
<body>
<!-- Topbar code start -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="{{ url_for('routes.dashboard') }}">Dashboard</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
{% if current_user.is_authenticated %}
<li class="nav-item active">
<a class="nav-link" href="{{ url_for('routes.portfolio_data_entry') }}">Portfolio Data Entry</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('routes.portfolio_data_entry_dashboard') }}">Portfolio Data Entry Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('routes.stock') }}">Stock</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('routes.account_page') }}">Account</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('routes.logout') }}">Log Out</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for('routes.login') }}">Home</a>
</li>
{% endif %}
</ul>
</div>
</nav>
<!-- Topbar code end -->
<!-- Sidebar code start end -->
<nav class="navbar navbar-expand d-flex flex-column align-item-start" id="sidebar">
<a href="#" class="navbar-brand text-light mt-5">
<div class="display-5 font-weight-bold">THANOS</div>
</a>
<ul class="navbar-nav d-flex flex-column mt-5 w-100">
<li class="nav-item w-100">
Home
</li>
<li class="nav-item w-100">
About
</li>
<li class="nav-item w-100">
Blog
</li>
<li class="nav-item dropdown w-100">
Service
<ul class="dropdown-menu w-100" aria-labelledby="navbarDropdown">
<li>Service 01</li>
<li>Service 02</li>
<li>Service 03</li>
</ul>
</li>
<li class="nav-item w-100">
Contact
</li>
</ul>
</nav>
<section class="p-4 my-container">
<button class="btn my-4" id="menu-btn">Toggle Sidebar</button>
<h1>Sidebar Navigation</h1>
<p class="text-dark">Lorem ipsum</p>
<p class="text-dark">Lorem ipsum</p>
</section>
<!-- custom js start -->
<script>
var menu_btn = document.querySelector("#menu-btn")
var sidebar = document.querySelector("#sidebar")
var container = document.querySelector(".my-container")
menu_btn.addEventListener("click", () => {
sidebar.classList.toggle("active-nav")
container.classList.toggle("active-cont")
})
</script>
<!-- custom js start -->
<!-- Sidebar code end -->
<!-- Body block container format start -->
<div class="container">
{% block body %}
{% endblock body %}
</div>
<!-- Body block container format end -->
<!-- Javascript start -->
<script src="/static/js/base.js"></script>
<!-- Javascript start -->
</body>
</html>
And this is the styles css file that starts with the topbar, then the sidebar is there too, this is where I got stuck in isolating the two from each other.
styles.css
.send-button {
background: #54C7C3;
width: 100%;
font-weight: 600;
color: #fff;
padding: 8px 25px;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.g-button {
color: #fff !important;
border: 1px solid #EA4335;
background: #ea4335 !important;
width: 100%;
font-weight: 600;
color: #fff;
padding: 8px 25px;
}
.my-input {
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
cursor: text;
padding: 8px 10px;
transition: border .1s linear;
}
.header-title {
margin: 5rem 0;
}
h1 {
font-size: 31px;
line-height: 40px;
font-weight: 600;
color: #4c5357;
}
h2 {
color: #5e8396;
font-size: 21px;
line-height: 32px;
font-weight: 400;
}
.login-or {
position: relative;
color: #aaa;
margin-top: 10px;
margin-bottom: 10px;
padding-top: 10px;
padding-bottom: 10px;
}
.span-or {
display: block;
position: absolute;
left: 50%;
top: -2px;
margin-left: -25px;
background-color: #fff;
width: 50px;
text-align: center;
}
.hr-or {
height: 1px;
margin-top: 0px !important;
margin-bottom: 0px !important;
}
#media screen and (max-width: 480px) {
h1 {
font-size: 26px;
}
h2 {
font-size: 20px;
}
}
.container .form-1 {
width: 25rem;
text-align: center;
margin: 3rem 0 0 22rem;
}
/* Sidebar section */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
background-color: #fff;
}
.navbar {
width: 250px;
height: 100vh;
position: fixed;
margin-left: -300px;
background-color: #7952b3;
transition: 0.4s;
}
.nav-link {
font-size: 1.25em;
}
.nav-link:active,
.nav-link:focus,
.nav-link:hover {
background-color: #ffffff26;
}
.dropdown-menu {
background-color: #7952b3;
}
.dropdown-item:active,
.dropdown-item:focus,
.dropdown-item:hover {
background-color: #ffffff26;
}
.my-container {
transition: 0.4s;
}
/* for navbar */
.active-nav {
margin-left: 0;
}
/* for main section */
.active-cont {
margin-left: 250px;
}
#menu-btn {
background-color: #7952b3;
color: #fff;
}
#menu-btn:focus {
box-shadow: 0 0 0 0.25rem #7952b344;
}

Content stuck to navbar

Photo of the page
I have my website's content somehow stuck to the navigation menu. I have tried putting it in a different div but nothing has worked for me so far, neither replacing the placing of the container class. I dont understand why the body's main content wont align underneath the navigational menu and be in its own section so that it doesn't leak out. Any help would be greatly appreciated.
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
padding: 0;
height: 100%;
max-width: calc(100vw - 20px);
min-height: 100vh;
}
body {
width: 100%;
overflow-x: hidden;
}
#container {
min-height: 100%;
position: relative;
width: 100%;
}
main {
margin-left: 100px;
}
/*
html {
display: block;
}
/*
/* SCROLL BAR CSS STARTS */
body::-webkit-scrollbar {
width: 0.30rem;
}
body::-webkit-scrollbar-track {
background: #212429;
}
body::-webkit-scrollbar-thumb {
background: #fc3218;
}
/* SCROLL BAR CSS ENDS */
/* NAV BAR CSS STARTS */
.logo {
margin-right: 5px;
}
.my-nav {
position: absolute;
display: flex;
align-items: center;
justify-content: space-between;
padding: 15px;
}
.navbar-light .navbar-nav .nav-link {
color: white;
}
.navbar-nav>li {
padding-left: 35px;
padding-right: 55px;
float: none;
display: table-cell;
text-align: center;
font-size: 14px;
}
.navbar-light .navbar-nav .nav-link:focus,
.navbar-light .navbar-nav .nav-link:hover {
color: #fc3218;
}
.navbar-light .navbar-nav .nav-link:focus,
.navbar-light .navbar-nav .nav-link:active {
color: #fc3218;
}
.navbar {
margin-top: 0px;
margin-left: 10px;
width: 100%;
background: #22252a;
}
.dropdown-menu {
color: white;
background-color: #fc3218;
}
.dropdown-item {
color: white;
font-size: 12px;
}
/* NAV BAR CSS END */
/* SIDEBAR CSS STARTS */
.lateral-nav {
position: absolute;
top: 0;
left: 0;
width: 100px;
background: #fafafc;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
}
img {
width: 60px;
height: 45px;
margin-top: 3px;
}
.lateral-nav a {
writing-mode: vertical-lr;
text-orientation: mixed;
margin: 5px 0;
}
.socialbox {
position: fixed;
display: inline-block;
top: 50%;
left: 0;
width: 80px;
height: auto;
margin: -120px 0 0;
text-align: center;
}
.socialbox img {
display: inline-block;
width: 30px;
height: 30px;
padding: 5px;
margin: 4px;
box-sizing: border-box;
}
.socialbox::before {
content: "#Suivez-nous";
bottom: -180px;
left: -38px;
width: 150px;
font-size: 16px;
font-weight: 800;
letter-spacing: 0;
color: #000f33;
transform: rotate(-90deg);
}
.socialbox::after {
content: "";
bottom: -105px;
left: 50%;
width: 1px;
height: 110px;
margin: 0 0 0 -2px;
background-color: #dddee4;
}
.socialbox::after,
.socialbox::before {
position: absolute;
display: inline-block;
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
transform: translate(0, 0);
}
.socialbox .fa {
font-size: 20px;
color: #000f33;
-webkit-transition: all .4s linear;
transition: all .4s linear;
}
/* SIDEBAR CSS ENDS */
/* CARD DECK START */
.card-deck {
width: 90%;
margin: auto;
}
/* CARD DECK END */
/* Footer start */
footer {
background: #16222A;
background: -webkit-linear-gradient(59deg, #3A6073, #16222A);
background: linear-gradient(59deg, #3A6073, #16222A);
color: white;
width: calc(100% - 85px);
margin-left: 100px;
margin-right: -15px;
}
footer a {
color: #fff;
font-size: 14px;
transition-duration: 0.2s;
}
footer a:hover {
color: #FA944B;
text-decoration: none;
}
.copy {
font-size: 12px;
padding: 10px;
border-top: 1px solid #FFFFFF;
}
.footer-middle {
padding-top: 2em;
color: white;
}
/* Footer social icons */
ul.social-network {
list-style: none;
display: inline;
margin-left: 0 !important;
padding: 0;
}
ul.social-network li {
display: inline;
margin: 0 5px;
}
.social-network a.icoFacebook:hover {
background-color: #3B5998;
}
.social-network a.icoLinkedin:hover {
background-color: #007bb7;
}
.social-network a.icoFacebook:hover i,
.social-network a.icoLinkedin:hover i {
color: #fff;
}
.social-network a.socialIcon:hover,
.socialHoverClass {
color: #44BCDD;
}
.social-circle li a {
display: inline-block;
position: relative;
margin: 0 auto 0 auto;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
text-align: center;
width: 30px;
height: 30px;
font-size: 15px;
}
.social-circle li i {
margin: 0;
line-height: 30px;
text-align: center;
}
.social-circle li a:hover i,
.triggeredHover {
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-ms--transform: rotate(360deg);
transform: rotate(360deg);
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-o-transition: all 0.2s;
-ms-transition: all 0.2s;
transition: all 0.2s;
}
.social-circle i {
color: #595959;
-webkit-transition: all 0.8s;
-moz-transition: all 0.8s;
-o-transition: all 0.8s;
-ms-transition: all 0.8s;
transition: all 0.8s;
}
.social-network a {
background-color: #F9F9F9;
}
/* Footer end */
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/carousel/">
<link rel="stylesheet" href="style1.css">
<link rel="stylesheet" href="normalize.css">
<!-- Bootstrap core CSS -->
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<title>Hello, world!</title>
</head>
<body>
<div id="container">
<!-- Navigation menu -->
<header>
<nav class="my-nav navbar navbar-light navbar-expand-lg">
<button class="navbar-toggler" type="button" data-toggle="collapse" data- target="#navbarsExample08"
aria-controls="navbarsExample08" aria-expanded="false" aria- label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-md-center" id="navbarsExample08">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown08" data-toggle="dropdown" aria- haspopup="true"
aria-expanded="false">ACTIVITES</a>
<div class="dropdown-menu" aria-labelledby="dropdown08">
<a class="dropdown-item" href="#">Rafting</a>
<a class="dropdown-item" href="#">Canooing</a>
<a class="dropdown-item" href="#">Parachute</a>
<a class="dropdown-item" href="#">Soufflerie</a>
<a class="dropdown-item" href="#">Saut elastique</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">OFFRES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">EVENEMENTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">A PROPOS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ESPACE HANDICAP</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</ul>
</div>
</nav>
</header>
<!-- Navigation menu -->
<!-- Sidebar menu -->
<div class="lateral-nav position-fixed">
<img class="logo" src="./img/so.png" alt="">
<div class="socialbox ">
<img class="fa fa-facebook" src="./img/facebook.png" alt="">
<img class="fa fa-twitter" src="./img/twitter.png" alt="">
<img class="fa fa-youtube" src="./img/youtube.png" alt="">
</div>
</div>
<!-- Sidebar menu -->
<!-- Website Content -->
<main>
<section>
<!-- NOS ACTIVITES START -->
<h2 class="text-center">NOS ACTIVITES</h2>
<div class="card-deck ">
<div class="card text-center" style="width: 18rem;">
<div class="card-body rafting">
<h5 class="card-title">RAFTING</h5>
RÉSERVEZ
</div>
</div>
<div class="card text-center" style="width: 18rem; height: 15rem;">
<div class="card-body canooing">
<h5 class="card-title">CANNOING</h5>
RÉSERVEZ
</div>
</div>
<div class="card text-center" style="width: 18rem;">
<div class="card-body parachute">
<h5 class="card-title">PARACHUTE</h5>
RÉSERVEZ
</div>
</div>
<div class="card text-center" style="width: 18rem;">
<div class="card-body soufflerie">
<h5 class="card-title">SOUFFLERIE</h5>
RÉSERVEZ
</div>
</div>
<div class="card text-center" style="width: 18rem;">
<div class="card-body saut-elastique">
<h5 class="card-title">SAUT ELASTIQUE</h5>
RÉSERVEZ
</div>
</div>
</div>
<!-- NOS ACTIVITES END -->
</section>
</main>
</div>
<!-- Footer Start -->
<footer class="mainfooter" role="contentinfo">
<div class="footer-middle">
<div class="container">
<div class="row">
<div class="col-md-3 col-sm-6">
<!--Column1-->
<div class="footer-pad">
<h4>Heading 1</h4>
<ul class="list-unstyled">
<li></li>
<li>Payment Center</li>
<li>Contact Directory</li>
<li>Forms</li>
<li>News and Updates</li>
<li>FAQs</li>
</ul>
</div>
</div>
<div class="col-md-3 col-sm-6">
<!--Column1-->
<div class="footer-pad">
<h4>Heading 2</h4>
<ul class="list-unstyled">
<li>Website Tutorial</li>
<li>Accessibility</li>
<li>Disclaimer</li>
<li>Privacy Policy</li>
<li>FAQs</li>
<li>Webmaster</li>
</ul>
</div>
</div>
<div class="col-md-3 col-sm-6">
<!--Column1-->
<div class="footer-pad">
<h4>Heading 3</h4>
<ul class="list-unstyled">
<li>Parks and Recreation</li>
<li>Public Works</li>
<li>Police Department</li>
<li>Fire</li>
<li>Mayor and City Council</li>
<li>
</li>
</ul>
</div>
</div>
<div class="col-md-3">
<h4>Follow Us</h4>
<ul class="social-network social-circle">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-linkedin"></i></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-12 copy">
<p class="text-center">© Copyright 2018 - Company Name. All rights reserved.</p>
</div>
</div>
</div>
</div>
</footer>
<!-- Footer Ends -->
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous">
</script>
</body>
</html>
This is because of the position: absolute on .my-nav element. Just remove that or change it to relative and you should be good
Why do you use position: absolute for the my-nav? What position: absolute or fixed does, it pulls out the element (my-nav) from the document context. If you check this and debug in your browser, you can see that the header has height equal to 0.
In order to fix the card-deck layout, just simply remove the position absolute.
If you want the menu, to be visible when you scroll down the page, consider putting position: sticky on the header.
like:
header {
position: sticky;
top: 0; // need to apply top and left for position sticky to work
left: 0;
z-index: 5; // z-index, so it is at the top
}
.my-nav {
display: flex;
align-items: center;
justify-content: space-between;
padding: 15px;
}
You can add padding to the top of the div which contains the card deck :
.card-deck {
width: 90%;
margin: auto;
padding-top:50px;
}
for the heading to move down edit this part in HTML file:
<h2 style="padding-top:40px;" class="text-center">NOS ACTIVITES</h2>

Navbar dropdown item is moved when I click on it

I'm trying to set up a navbar that contains several items aligned to the right.
The problem is that when I click on the "notification" icon, I have my dropdown displayed, but my icons move in the navbar instead of staying fixed, I don't understand why
This is my code :
HTML :
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary justify-content-end">
<ul class="navbar-nav menu-right">
<div class="child child-right">
<!-- Parameters item -->
<li class="nav-item">
<a href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-cog"></i>
<span class="badge-sonar"></span>
</a>
<div class="dropdown-menu parametres" aria-labelledby="dropdownMenuMessage">
<a class="dropdown-item" href="#">My profile</a>
<a class="dropdown-item" href="#">Help</a>
<a class="dropdown-item" href="#">Setting</a>
</div>
</li>
<!-- Notifications item -->
<li class="nav-item">
<a href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-bell"></i>
</a>
<div class="dropdown-menu notifications" aria-labelledby="dropdownMenuMessage">
<div class="notifications-header">
<i class="fa fa-bell"></i>
Notifications
</div>
<!-- Notification content -->
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">
<div class="notification-content">
<div class="icon">
<i class="fas fa-check text-success border border-success"></i>
</div>
<div class="content">
<div class="notification-detail">Lorem ipsum dolor sit amet consectetur adipisicing
elit. In totam explicabo</div>
<div class="notification-time">
6 minutes ago
</div>
</div>
</div>
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-center" href="#">View all notifications</a>
</div>
</li>
</div>
</ul>
</nav>
SASS:
.navbar {
overflow: visible;
height: 56px;
z-index: 9999;
}
.notifications {
max-width: 250px;
margin-left: -200px;
margin-top: 5px;
.dropdown-item {
padding: .25rem 1rem;
}
.notifications-header {
padding: 0 1rem;
}
.notification-content {
display: flex;
.icon {
width: 40px;
height: 40px;
i {
width: 35px;
height: 35px;
text-align: center;
line-height: 35px;
}
}
.content {
line-height: 1.6;
padding-left: 5px;
width: calc(100% - 40px);
.notification-time {
font-size: .7rem;
color: #828282;
}
.notification-detail {
font-size: 12px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
}
.child {
display: flex;
flex-flow: row nowrap;
flex-grow: 0;
justify-content: flex-start;
align-items: stretch;
}
.child.child-right {
flex-grow: 1;
justify-content: flex-end;
}
.child>li{
padding-right: 50px;
}
And the jsfiddle : https://jsfiddle.net/kiuega/beat2zmn/11/
Can someone help me please ?
Styles are overridden by navbar.scss like drop-down is of static pos instead of absolute so here is the solution
Add these styles to you style sheet
.child > li {
padding-right: 50px;
position: relative;
}
.navbar-nav .dropdown-menu {
position: absolute;
float: none;
}
check margins and padding(in the child) check with the inspect element and see witch element change his position
If you open the devtools in your browser then you will see these classes on the dropdown panel:
.navbar-nav .dropdown-menu
(overwritten by navbar.scss)
If you remove the 'position: static', then it will work as expected.
And play with the top and left properties to get the right position.

Bootstrap navbar collapse opens in the wrong place

Navbar collapsed menu fits perfectly to the navbar in Safari browser and occupy full width of the viewport. However, in other browsers collapsed navbar is getting smaller and sticks to the very top of the page. Looks like it is not connected to the navbar itself and drops down from another reference point. Is this a browser prefix issue or something entirely wrong with my bootstrap structure?
.navbar {
height: 60px;
padding: 0;
margin: 0;
border-bottom: .1px solid black;
background: #ffffff;
}
.navbar-nav {
margin-top: 1.5em;
}
.navBut {
margin: 20px 0;
}
.navButBut {
border: 1px solid red;
}
.navbar-toggle {
border-color: black !important;
color: snow;
height: 30px;
width: 45px;
padding: 2px 5px 0;
margin: 15px 8% 15px 0;
}
.navbar-toggle:hover {
background-color: transparent !important;
}
.dropbut {
font-size: 1.5em;
color: black;
}
.fa-korvue {
color: #962715;
font-size: 3.5em;
line-height: -45%;
float: left;
margin: 5px 8% 0 12%;
}
.link_icon, .link_icon:link, .link_icon:visited, .link_icon:active {
color: #1e1e20;
padding: 0;
margin-right: 20px;
font-family: 'Arsenal', sans-serif;
font-size: 1.2em;
text-decoration: none;
outline: 0;
cursor: pointer;
background: transparent;
}
#collapse_menu {
margin-top: 1.2em;
}
#collapse_menu li a {
padding: 3px 8px;
margin-right: 5px;
border-radius: 3px;
}
#collapse_menu li a:hover {
background-color: rgba(0, 0, 0, 0.2) !important;
}
.hidden-xs {
margin-right: 18px;
}
#phone_handset {
color: black;
font-size: 1.7em;
vertical-align: 10%;
text-decoration: none;
outline: 0;
transition: 1s;
}
#phone_num {
display: inline;
margin-right: 4em;
vertical-align: 20%;
font-size: 1.3em;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<header>
<nav class="navbar navbar-fixed-top">
<div class="container-fluid">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="fa fa-th dropbut"></span>
</button>
<i class="fab fa-korvue"></i>
<div class="collapse navbar-collapse" id="myNavbar">
<ul id="collapse_menu" class="nav navbar-nav text-center">
<li><a class="link_icon scroll" name="1" href="#top_page_scroll">Начало</a></li>
<li><a class="link_icon scroll" name="2" href="#about_me_scroll">Обо мне</a></li>
<li><a class="link_icon scroll" name="3" href="#portfolio_scroll">Услуги</a></li>
<li><a class="link_icon scroll" name="4" href="#pricing_scroll">Цены</a></li>
<li><a class="link_icon scroll" name="5" href="#contact_me_scroll">Регистрация</a></li>
</ul>
<div class="navbar-nav navbar-right vertical-align">
<a id="phone_handset" class="fas fa-phone-volume hidden-xs" href="#"></a>
<a id="phone_num" class="link_icon hidden-xs" href="#">110-223-456-78</a>
</div>
</div>
</div>
</nav>
</header>
I finally fixed this issue. If you wrap navbar-toggle with <div class=“navbar-header”> then everything starts to work as expected. Now collapsed navbar occupies full width and sits in the right place. Thank #fnostro for the valuable tips.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<header>
<nav class="navbar navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="fa fa-th dropbut"></span>
</button>
<i class="fab fa-korvue"></i>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul id="collapse_menu" class="nav navbar-nav text-center">
<li><a class="link_icon scroll" name="1" href="#top_page_scroll">Начало</a></li>
<li><a class="link_icon scroll" name="2" href="#about_me_scroll">Обо мне</a></li>
<li><a class="link_icon scroll" name="3" href="#portfolio_scroll">Услуги</a></li>
<li><a class="link_icon scroll" name="4" href="#pricing_scroll">Цены</a></li>
<li><a class="link_icon scroll" name="5" href="#contact_me_scroll">Регистрация</a></li>
</ul>
<div class="navbar-nav navbar-right vertical-align">
<a id="phone_handset" class="fas fa-phone-volume hidden-xs" href="#"></a>
<a id="phone_num" class="link_icon hidden-xs" href="#">110-223-456-78</a>
</div>
</div>
</div>
</nav>
</header>

Aligning multiple images in Bootstrap

I have two image images that I cant work out how to align in the centre of my container, I have tried using text-align and justify-content but nothing seems to be working. This is the same for my nav bar where I cant work out how to align the text to the right but keep the logo to the left of the bar, which I though would be the text-align? Thanks
<style>
.buttons-1{
background-color: darkgray;
padding-top: 30px;
text-align: center;
}
.row-1{
background-color: ghostwhite;
}
.photography {
opacity: 1;
display: block;
width: 100%;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
}
.middle {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%)
}
.fadehover:hover img {
opacity: 0.3;
}
.fadehover:hover .middle {
opacity: 1;
}
.text {
background-color: gray;
color: greenyellow;
font-size: 16px;
padding: 16px 32px;
}
.col-md-3{
padding: 0;
}
.container-fluid {
height:100%;
min-height: 100%;
}
.row{
width:100%;
margin:0;
padding:0;
height:100%;
}
</style>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">
<a class="navbar-brand" href="#">
<img src="Photos/logowhite.png" alt="logo" style="width:40px;"></a>
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a class="nav-link" href="photography.html">Photography</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 3</a>
</li>
</ul>
</nav>
<div class="container-fluid buttons-1 ">
<div class="row ">
<div class="col-md-3 d-none d-md-block photography fadehover">
<a href="photography.html">
<img src="Photos/Buttons/photography%20button.png" alt="Photography" class="img-fluid photography"/>
<div class="middle">
<div class="text">Photography</div>
</div>
</a>
</div>
<div class="col-md-3 d-none d-md-block photography fadehover">
<a href="photography.html">
<img src="Photos/Buttons/photography%20button.png" alt="Photography" class="img-fluid photography"/>
<div class="middle">
<div class="text">Other</div>
</div>
</a>
</div>
</a>
</div>
</div>
</div>
Sse the css
.fadehover{text-align:center !important; display:block;}