hi i recenty used the bootstrap 4 offcanvas template to build my website
http://v4-alpha.getbootstrap.com/examples/offcanvas/#
now i want to make my side-bar follow as the users scrolls but bootstrap removed the affix class and recommends using css position sticky. I tried to do this and target the sidebar but it screws up the layout. targeting the .nav doesnt work either
Html
<div class="container-fluid header navbar-fixed-top">
<div class="row">
<div class="hidden-md-up col-xs-2">
<button type="button" class="btn btn-secondary" data-toggle="offcanvas"><i class="fa fa-bars"></i></button>
</div>
<div class="col-md-12 col-sm-8 col-xs-8">
<img src="images/logo.gif" class="img-fluid center-block" alt="emblem">
</div>
</div>
</div><!-- /HEADER -->
<div class="container-fluid">
<div class="row row-offcanvas row-offcanvas-left">
<div class="col-md-2 col-sm-2 col-xs-4 sidebar-offcanvas" id="sidebar">
<ul class="nav nav-stacked">
<li class="nav-item">
<a class="nav-link" href="#home">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#about">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#area">Locations</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#deals">Deals</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact Us</a>
</li>
</ul>
</div><!-- /Navigation -->
<section id="home">
<div class="row">
<div class="col-md-6 col-md-offset-5 col-sm-8 col-sm-offset-2 col-xs-10 col-xs-offset-1">
<img src="images/mazda2.gif" alt="Mazda2" class="img-fluid center-block">
</div>
<div class="col-md-6 col-md-offset-5 col-xs-12 text-xs-center">
<h3>Perth, Western Australia</h3>
</div>
</div>
</section><!-- HOME -->
<section id="about">
<div class="about-me">
<h3>About Us</h3>
</div>
</section><!-- ABOUT -->
</div><!--ROW -->
</div><!-- CONTAINER-FLUID -->
CSS
/*
* Style tweaks
* --------------------------------------------------
*/
html,
body {
overflow-x: hidden; /* Prevent scroll on narrow devices */
}
body {
padding-top: 7em;
position: relative;
}
/*
* Off Canvas
* --------------------------------------------------
*/
#media screen and (max-width: 767px) {
.row-offcanvas {
position: relative;
-webkit-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
}
.row-offcanvas-left {
left: 0;
}
.row-offcanvas-right {
right: 0;
}
.row-offcanvas-left
.sidebar-offcanvas {
left: -33%; /* 4 columns */
}
.row-offcanvas-right
.sidebar-offcanvas {
right: -33%; /* 4 columns */
}
.row-offcanvas-left.active {
left: 33%; /* 4 columns */
}
.row-offcanvas-right.active {
right: 33%; /* 4 columns */
}
.sidebar-offcanvas {
position: absolute;
top: 0;
width: 33%; /* 4 columns */
}
}
/*
* Custom Style
* --------------------------------------------------
*/
#sidebar {
background-color: white;
position:absolute;
height:100vh;
}
.header {
background-color: #232323;
}
.btn-secondary {
background-color: #232323;
border-color: #232323;
margin-top:0.3em;
}
/*
* HOME
*/
#home {
background-color: #434343;
height: 100vh;
width: 100vw;
}
It probably got something to do with my sidebar-off canvas and sidebar position. But without mysidebar position absolute my section contents gets pushed down. I triedremoving itandusing col-x-x class but no go :(
i think you should use:
#media screen and (min-width: 768px) {
.sidebar-offcanvas .nav-stacked {
position: fixed;
top: 8em;
width: 33%;
}
}
Read more about position: fixed at: Affix is not working in Bootstrap 4 alpha
Related
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>
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>
I am having an issue with the jumbotron, white space appear under it for some reason i don't know if its because of my code or a mistake that i made some where . i have been at it for two days now .i copy the code for the jumbotron on the bootstrap 4 website. i could use some help on this . As you can see by the picture white space appear under it.
.container_fluid.one {
background-size: cover;
height: 100vh;
background-color: #43E8E4;
}
.nav-item {
padding-right:20px;
font-size: 18px;
}
.info h1 {
margin-top: 170px;
line-height: 50px;
}
.info p {
font-size: 15px;
}
span {
color: #fffc00;
}
span .gold{
color: #fffc00;
}
.info p {
font-size: 18px;
}
.white {
color: #fff;
}
.navbar-dark .navbar-nav .nav-link:focus, .navbar-dark .navbar-nav .nav-link:hover {
color: #fffc00;
}
.leader {
margin-top: 110px;
width: 457px;
height: 316px;
}
.down {
margin-top: 60px;
}
.container_fluid.two {
background-size: cover;
min-height: 100vh;
background-color: #43E8E4;
}
.jumbotron {
margin-top: 0px;
}
<div class="container_fluid one">
<!--Navbar -->
<nav class="mb-1 navbar navbar-expand-lg navbar-dark orange lighten-1">
<a class="navbar-brand" href="#"><i class='bx bxl-stripe bx-md' style="color:#fffc00;"></i></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent-555"
aria-controls="navbarSupportedContent-555" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent-555">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">
<span class="gold">Home</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
</div>
</nav>
<!--/.Navbar -->
<section data-aos="zoom-in"data-aos-duration="1900">
<div class="container">
<div class="row">
<div class="col-md-6 text-white info">
<h1>I'll go above and beyond for <span>you.</span></h1>
<p>The world's best.</p>
<p><span>I am good at what i do.</span></p>
<button type="button" class="btn btn-outline-info white">Learn More</button>
</div>
<div class="col-md-6 text-right">
<img class="img-fluid leader" src="/images/undraw_site_stats_l57q.svg" alt="Responsive image">
</div>
</div>
</div>
</section>
<div class="container">
<div class="row">
<div class="col-md-12 text-center down">
<i class='bx bx-down-arrow bx-md bx-fade-down' style="color:#fffc00;"></i>
</div>
</div>
</div>
</div>
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1 class="display-4">Fluid jumbotron</h1>
<p class="lead">This is a modified jumbotron that occupies the entire horizontal space of its parent.</p>
</div>
</div>
<div class="container_fluid two">
Include these lines of code in your CSS file
.jumbotron {
margin-bottom: 0px;
}
It is because of:
.jumbotron {
margin-bottom: 2em;
}
So if you want to remove that, simply give a class to your div e.g.: jumbotron-override and add this code to css:
.jumbotron-override {
margin-bottom: 0px;
}
The result can be seen on jsfiddle: https://jsfiddle.net/nabtron/1kesqj8f/4/ (full page: https://fiddle.jshell.net/nabtron/1kesqj8f/4/show/ )
I hope it solves your problem :)
I tried to override your code by commenting margin-bottom: 2rem; then white space disappear
.jumbotron {
/* padding: 2rem 1rem; */
/*margin-bottom: 2rem; */
background-color: #e9ecef;
border-radius: .3rem;
}
I had to put !important after margin: 0px to make it work
.jumbotron {
margin-bottom: 0px!important;
}
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;}
I want whenever my screen-size reaches 1512 x 473 for the content inside content.php to not overlap onto the left sidebar. As this makes the sidebar links unreadable. Would really appreciate the help guys :)
content.php
<div class="container-fluid">
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">
Dashboard
</h1>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-xs-3 col-xs-3">
<div class="panel panel-default">
<div class="panel-heading text-center">Panel heading without title</div>
<div class="panel-body text-center">
Panel content
</div>
</div>
</div>
<div class="col-xs-3 col-xs-3">
<div class="panel panel-default">
<div class="panel-heading text-center">Appointments</div>
<div class="panel-body text-center">
Panel content
</div>
</div>
</div>
<div class="col-xs-3 col-xs-3">
<div class="panel panel-default">
<div class="panel-heading text-center">Panel heading without title</div>
<div class="panel-body text-center">
Panel content
</div>
</div>
</div>
<div class="col-xs-3 col-xs-3">
<div class="panel panel-default text-center">
<div class="panel-heading">Panel heading without title</div>
<div class="panel-body text-center">
Panel content
</div>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
sidebar.php
<aside class="sidebar">
<ul class="menu" id="menu">
<li><i class="fa fa-dashboard"></i> Dashboard</li>
<li><i class="fa fa-users"></i> Doctors</li>
<li><i class="fa fa-users"></i> Nurses</li>
<li><i class="fa fa-users"></i> Patients</li>
<li><i class="fa fa-address-book-o"></i> Appointments</li>
</ul>
</aside>
CSS:
.sidebar
{
float:left;
position: absolute;
top:0px;
left:0px;
background-color: #E0E0E0;
width:200px;
height: 100%;
}
First of all, most screen-sizes I used (not only 1512 x 473) had overlapping text on the sidebar. So I'm not sure that I have enough info to help you.
I took a bootstrap example
and changed the content to what you asked for. I also included a toggle button for the sidebar.
Here's the HTML:
<html lang="en">
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
Sidebar Title
</a>
</li>
<li>
Dashboard
</li>
<li>
Doctors
</li>
<li>
Nurses
</li>
<li>
Patients
</li>
<li>
Appointments
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Dashboard</h1>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-xs-3 col-xs-3">
<div class="panel panel-default">
<div class="panel-heading text-center">Panel heading without title</div>
<div class="panel-body text-center">
Panel content
</div>
</div>
</div>
<div class="col-xs-3 col-xs-3">
<div class="panel panel-default">
<div class="panel-heading text-center">Appointments</div>
<div class="panel-body text-center">
Panel content
</div>
</div>
</div>
<div class="col-xs-3 col-xs-3">
<div class="panel panel-default">
<div class="panel-heading text-center">Panel heading without title</div>
<div class="panel-body text-center">
Panel content
</div>
</div>
</div>
<div class="col-xs-3 col-xs-3">
<div class="panel panel-default text-center">
<div class="panel-heading">Panel heading without title</div>
<div class="panel-body text-center">
Panel content
</div>
</div>
</div>
</div>
Toggle Menu
</div>
</div>
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
Here's the CSS:
body {
overflow-x: hidden;
}
/* Toggle Styles */
#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper.toggled {
padding-left: 250px;
}
#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 250px;
width: 0;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: #eee;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper.toggled #sidebar-wrapper {
width: 250px;
}
#page-content-wrapper {
width: 100%;
position: absolute;
padding: 15px;
}
#wrapper.toggled #page-content-wrapper {
position: absolute;
margin-right: -250px;
}
/* Sidebar Styles */
.sidebar-nav {
position: absolute;
top: 0;
width: 250px;
margin: 0;
padding: 0;
list-style: none;
background-color: #eee;
}
.sidebar-nav li {
text-indent: 20px;
line-height: 40px;
}
.sidebar-nav li a {
display: block;
text-decoration: none;
color: #555;
}
.sidebar-nav li a:hover {
text-decoration: none;
color: #666;
background: rgba(0, 0, 0, 0.2);
}
.sidebar-nav li a:active,
.sidebar-nav li a:focus {
text-decoration: none;
}
.sidebar-nav > .sidebar-brand {
height: 65px;
font-size: 18px;
line-height: 60px;
}
.sidebar-nav > .sidebar-brand a {
color: #777;
}
.sidebar-nav > .sidebar-brand a:hover {
color: #000;
background: none;
}
/* When the screen size is small, the sidebar will automatically collapse. */
#media(min-width:768px) {
#wrapper {
padding-left: 250px;
}
#wrapper.toggled {
padding-left: 0;
}
#sidebar-wrapper {
width: 250px;
}
#wrapper.toggled #sidebar-wrapper {
width: 0;
}
#page-content-wrapper {
padding: 20px;
position: relative;
}
#wrapper.toggled #page-content-wrapper {
position: relative;
margin-right: 0;
}
}
And the Javascript (for the collapsible sidebar)
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
I hope this helps your project!
Codepen: http://codepen.io/penguoir/pen/YNMoyW
You can use #media query just add div tag in the sidebar.php and put the content.php to the div tag and display:none the div. when it reach the size 1512
cheer's