I have the following HTML for a Bootstrap sidebar but I cannot get the "push" transition to work. Whenever I trigger the JavaScript, the sidebar just toggles between the two states. Am I putting the correct transition CSS on the correct elements?
HTML:
<div class="wrapper">
<div class="row row-offcanvas row-offcanvas-left">
<!-- sidebar -->
<div class="column col-sm-3 col-xs-1 sidebar-offcanvas" id="sidebar">
<ul class="nav" id="logo">
<li><a data-toggle="offcanvas" href="#"><i class="glyphicon glyphicon-option-vertical"></i> <span class="collapse in hidden-xs">
<img class="img-responsive2" src="./Pension-Solutions-185x51.png">
</span></a></li>
</ul>
<ul class="nav" id="menu">
<li><i class="glyphicon glyphicon-stats"></i> <span class="collapse in hidden-xs">Work in progress</span></li>
<li><i class="glyphicon glyphicon-th-list"></i> <span class="collapse in hidden-xs">Management information</span></li>
<li><i class="glyphicon glyphicon-user"></i> <span class="collapse in hidden-xs">Member access</span></li>
<li><i class="glyphicon glyphicon-dashboard"></i> <span class="collapse in hidden-xs">Membership statistics</span></li>
</ul>
<ul class="nav" id="logout">
<li><i class="glyphicon glyphicon-share"></i> <span class="collapse in hidden-xs">Logout</span></li>
</ul>
</div>
<!-- /sidebar -->
<!-- main right col -->
<div class="column col-sm-9 col-xs-11" id="main">
<p>
PAGE CONTENT
</p>
</div>
<!-- /main -->
</div>
</div>
CSS:
#media screen and (max-width: 768px) {
#sidebar {
min-width: 44px;
}
#main {
width: 1%;
left: 0;
}
#sidebar .visible-xs {
display:inline !important;
}
.row-offcanvas {
position: relative;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
.row-offcanvas-left.active {
left: 45%;
}
.row-offcanvas-left.active .sidebar-offcanvas {
left: -45%;
position: absolute;
top: 0;
width: 45%;
}
}
#media screen and (min-width: 768px) {
.row-offcanvas {
position: relative;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
.row-offcanvas-left.active {
left: 3%;
}
.row-offcanvas-left.active .sidebar-offcanvas {
left: -3%;
position: absolute;
top: 0;
width: 3%;
text-align: center;
min-width:42px;
}
#main {
left: 0;
}
}
JavaScript:
$(document).ready(function() {
$('[data-toggle="offcanvas"]').click(function() {
$('.row-offcanvas').toggleClass('active');
$('.collapse').toggleClass('in').toggleClass('hidden-xs').toggleClass('visible-xs');
});
})
The transition should have been applied to the #sidebar element
Related
I am trying to create a navigation sidebar with Angular and Bootstrap but my navigation items are not displaying the way they should.
APP Component HTML
<div class="container-fluid">
<div class="row" id="header">
<div class="col-md-12">
<app-admin-header></app-admin-header>
</div>
</div>
<div class="row">
<div class="col-md-2" id="sidebar-parent">
<app-sidebar-menu></app-sidebar-menu>
</div>
<div class="jumbotron col-md-10" id="content-parent">
<router-outlet></router-outlet>
</div>
</div>
</div>
APP Component CSS
#sidebar-parent {
position:relative;
top:0;
left:0;
}
#content-parent {
position:relative;
top:0;
left:0px;
}
HEADER HTML
<div id="header-wrapper">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<!--button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button-->
<div class="col-md-12">
<ul class="navbar-nav ml-auto">
<li class="sidebar-brand">
<a href="#">
</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Coupons</a>
</li>
</ul>
</div>
</nav>
</div>
HEADER CSS
#header-wrapper {
background: #35acdf;
margin-bottom: 7px;
}
.navbar {
background: #35acdf;
}
SIDEBAR HTML
<div id="page-wrapper">
<div id="page-viewport">
<div id="sidebar">
<div id="sidebar-header">
<a href="#" class="toggle-sidebar">Sidebar
<span class="pull-right">
<a href="#" class="toggle-sidebar btn btn-default">
<span class="fa fa-bars"></span>
</a>
</span>
</a>
</div>
<ul class="nav nav-pills nav-stacked">
<li><span class="fa fa-shopping-bag"></span> Dashboard</li>
<li><span class="fa fa-list"></span> Categories</li>
<li><span class="fa fa-lock"></span> Companies</li>
<li><span class="fa fa-industry"></span> Coupons</li>
<li><span class="fa fa-male"></span> Products</li>
<li><span class="fa fa-list"></span> Sales</li>
<li><span class="fa fa-lock"></span> Deals</li>
</ul>
</div>
</div>
</div>
SIDEBAR CSS
#page-wrapper {
position: relative;
width: 100%;
height: 100%;
left: 0;
}
#page-viewport {
position: relative;
width: 100%;
height: 100%;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#sidebar {
position: relative;
width: 100%;
height: 100%;
left: 0px;
border-right: 1px solid #f0f0f0;
background-color: #f9f9f9;
padding-left: 15px;
list-style: none;
}
#sidebar h3 {
display:inline;
position:relative;
top:5px;
left:5px;
}
#sidebar a:hover {
text-decoration:none;
}
#sidebar-header {
height: 40px;
border-bottom:1px solid #f0f0f0;
}
.sidebar li {
position: absolute;
line-height: 20px;
width: 100%;
padding: 10px 0 10px 20px;
}
#page-wrapper.show-sidebar #page-viewport {
-webkit-transform: translateX(200px);
}
#page-wrapper.show-sidebar #sidebar-page-content {
width: -webkit-calc(100% - 250px);
}
You can see from the image below that the list items "Products" and "Deals" follows their previous items instead of occupying separate line.
I want each item to occupy separate line.
The default .nav class of bootstrap is display: flex; flex: wrap;.
Just add the flex-column class tou your nav and you should be fine.
Docs: https://getbootstrap.com/docs/4.0/components/navs/#vertical
I'm currently building a sidebar using bootstrap.
I have the bar built, however when I scroll down the page, a blank space appears between the sidebar and the navbar. Is there anyway that I can make the navbar stay stationary, or fill in the blank space when the page is scrolled down? I have included screenshots and code. Normal, before scrolling
After Scrolling
Code listed below:
<nav class = "navbar navbar-inverse">
<div class = "container-fluid">
<div class = "navbar-header">
<button type = "button" class="navbar-toggle" data-
toggle="collapse" data-target="#myNavbar">
<span class= "icon-bar"></span>
<span class= "icon-bar"></span>
<span class= "icon-bar"></span>
</button>
<a class = "navbar-brand" href="Home.html">Stephens Catering</a>
</div>
<div class = "collapse navbar-collapse" id="myNavbar">
<ul class = "nav navbar-nav">
<li>Home</li>
<li>About Us</li>
<li class="dropdown">
<a class = "dropdown-toggle" data-toggle="dropdown"
href="OurProducts.html">Our Products
<span class = "caret"></span></a>
<ul class = "dropdown-menu">
<li>Cookers</li>
<li>Fridges</li>
<li>Misc</li>
</ul>
</li>
<li>Contact us</li>
</ul>
<ul class = "nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-user">
</span> Sign Up</a></li>
<li><a href="#"><span class="glyphicon glyphicon-log-in">
</span> Login</a></li>
</ul>
</div>
</div>
</nav>
<!--The sidebar for the products pages -->
<div id = "wrapper">
<!-- Sidebar -->
<div id = "sidebar-wrapper">
<ul class="sidebar-nav">
<li class = "sidebar-brand">
Categories
</li>
<li>
Cookers
</li>
<li>
Fridges
</li>
<li>
Misc
</li>
</ul>
</div>
<!-- Sidebar Wrapper -->
<!-- Page Content -->
<!-- Button to toggle sidebar menu -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class = "row">
<div class = "col-lg-12">
Toggle Menu
</div>
</div>
</div>
</div>
The stylesheet:
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;
}
#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: #000;
-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:250%;
margin:0;
padding:0;
list-style: none;
}
.sidebar-nav li {
text-indent:20px;
line-height: 40px
}
.sidebar-nav li a {
display: block;
text-decoration: none;
color:#999999;
}
.sidebar-nav li a:hover {
text-decoration: none;
color:#fff;
background:rgba(255,255,255,0.2);
}
.sidebar-nav li a:active,
.sidebar-nav li focus {
text-decoration: none;
}
.sidebar-nav > .sidebar-brand {
height:65px;
font-size:18px;
line-height: 60px;
}
.sidebar-nav > .sidebar-brand a {
color:#999999;
}
.sidebar-nav > sidebar-brand a:hover{
color:#fff;
backround:none;
}
#media(min-width: 768px) {
#wrapper {
padding-left:0;
}
#wrapper.toggled {
padding-left:250px;
}
#sidebar-wrapper {
width:0;
}
#wrapper.toggled #sidebar-wrapper {
width:250px;
}
#page-content-wrapper {
padding:20px;
position: relative;
}
#wrapper.toggled #page-content-wrapper {
position: relative;
margin-right:0;
}
}
I think your issue is using the position:fixed in the #sidebar-wrapper css class which causes it to stick to the positioned place on the screen without scroll affect. If you want it to stick right below the top navbar then change it to position:absolute and your problem will be hopefully resolved. And if you want it to stick to top and also keep the black background of the sidebar to follow through to the bottom then change #sidebar-wrapper position:relative.
The best way for you to understand this is to understand the effects of the values of the position property. Following is a link to the w3schools definition of position property and it's values with description.
https://www.w3schools.com/cssref/pr_class_position.asp
Hope this helps.
Try adding this to your actual sidebar-wrapper css rule:
.sidebar-wrapper{
top:0;
}
I am having difficulty getting the logo image (red) to overflow the menu bar, currently the menu bar is extended once the logo is added (see the image).
The HTML Code:
<div id="page" class="page">
<div class="pixfort_normal_1" id="section_header_2_dark">
<div class="header_nav_1 dark pix_builder_bg" style="background-image: none; background-color: rgb(13, 52, 64); padding-top: 0px; padding-bottom: 0px; box-shadow: none; border-color: rgb(255, 255, 255); background-size: auto; background-attachment: scroll; background-repeat: repeat;">
<div class="container">
<div class="sixteen columns firas2">
<nav role="navigation" class="navbar navbar-white navbar-embossed navbar-lg pix_nav_1">
<div class="containerss">
<div class="navbar-header">
<button data-target="#navbar-collapse-02" data-toggle="collapse" class="navbar-toggle pix_text" type="button">
<span class="sr-only ">Toggle navigation</span>
</button>
<img src="images/LOGO1.png" class="pix_nav_logo">
</div>
<div id="navbar-collapse-02" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active propClone">Home</li>
<li class="propClone">About</li>
<li class="propClone">Workshops and Training</li>
<li class="propClone">Contact</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
</div>
</div><!-- container -->
</div>
</div>
The CSS Code:
.pix_nav_1 ul li a {
color: rgba(0, 0, 0, 0.5);
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
};
.pix_nav_1 ul li a:hover {
//color: rgba(0,0,0,0.85);
opacity: 0.6;
}
.header_nav_1 {
padding: 0px !important;
box-shadow: none;
}
.pix_nav_logo {
background: url(../images/t_logo.png) no-repeat;
padding-top: 0px;
overflow: visible;
}
.navbar-center {margin-left: auto;margin-right: auto;float: none;position:
relative;text-align: center; }
.navbar-center li { text-align: center;float: none;display: inline-block;}
Could someone please assist me to how I can get the logo to overflow the menu. Thanks in advance!
Try this
.pix_nav_logo {
position: absolute;
}
You can adjust the logo by playing with different values for css property left and right for .pix_nav_logo.
position: absolute : The element is positioned relative to its first positioned (not static) ancestor element.
.pix_nav_logo {
background: url(../images/t_logo.png) no-repeat;
padding-top: 0px;
overflow: visible;
width: 100px; // This for your logo size
position: absolute; // This is absolute position of logo
}
.pix_nav_1 ul li a {
color: rgba(0, 0, 0, 0.5);
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
}
;
.pix_nav_1 ul li a:hover {
//color: rgba(0,0,0,0.85);
opacity: 0.6;
}
.header_nav_1 {
padding: 0px !important;
box-shadow: none;
}
.pix_nav_logo {
background: url(../images/t_logo.png) no-repeat;
padding-top: 0px;
overflow: visible;
width: 100px;
position: absolute;
}
.navbar-center {
margin-left: auto;
margin-right: auto;
float: none;
position: relative;
text-align: center;
}
.navbar-center li {
text-align: center;
float: none;
display: inline-block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div id="page" class="page">
<div class="pixfort_normal_1" id="section_header_2_dark">
<div class="header_nav_1 dark pix_builder_bg" style="background-image: none; background-color: rgb(13, 52, 64); padding-top: 0px; padding-bottom: 0px; box-shadow: none; border-color: rgb(255, 255, 255); background-size: auto; background-attachment: scroll; background-repeat: repeat;">
<div class="container">
<div class="sixteen columns firas2">
<nav role="navigation" class="navbar navbar-white navbar-embossed navbar-lg pix_nav_1">
<div class="containerss">
<div class="navbar-header">
<button data-target="#navbar-collapse-02" data-toggle="collapse" class="navbar-toggle pix_text" type="button">
<span class="sr-only ">Toggle navigation</span>
</button>
<img src="http://www.hjmt.com/blog/wp-content/uploads/2012/08/Logo_TV_2015.png" class="pix_nav_logo">
</div>
<div id="navbar-collapse-02" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active propClone">Home</li>
<li class="propClone">About</li>
<li class="propClone">Workshops and Training</li>
<li class="propClone">Contact</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
</div>
</div>
<!-- container -->
</div>
</div>
My code is a bit messy as i am learning bootstrap.
How do i go about resolving the empty space between the top and side bar
<!DOCTYPE html>
<html lang="en">
<style type="text/css">
.navbar-brand>img {
max-height: 100%;
height: 100%;
width: auto;
margin: 0 auto;
/* probably not needed anymore, but doesn't hurt */
-o-object-fit: contain;
object-fit: contain;
}
</style>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Simple Sidebar - Start Bootstrap Template</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/simple-sidebar.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<!-- <span class="sr-only">Toggle navigation</span> -->
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://disputebills.com"><img src="http://disputebills.com/site/uploads/2015/10/dispute.png" alt="Dispute Bills"></a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</div>
</nav>
</div>
<div id="wrapper">
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
TER
</a>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class = "row">
<div class = "panel panel-default">
<div class = "panel-header">
<h1> TER</H1>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-3">
<div class = "panel panel-default">
<div class = "panel-body">
<img src="images.jpg" class="img-circle " alt="Cinque Terre" width="200" height="200">
</div>
Toggle Menu
</div>
</div>
<div class="col-lg-6 col-md-6">
</div>
<div class="col-lg-3 col-md-3">
<h1>TER</h1>
<div class = "panel panel-default">
</div>
</div>
</div>
</div>
</div>
<div id ="charts-wrapper">
<div class = "container-fluid">
<div class = "row">
<div col = "col-lg-3">
haha
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
<!-- /#wrapper -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Menu Toggle Script -->
<script>
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
</script>
</body>
Attached is a snippet of the page.
I would like the side and top bar to be joined together as bar of the template frame of my webpage.
/*!
* Start Bootstrap - Simple Sidebar HTML Template (http://startbootstrap.com)
* Code licensed under the Apache License v2.0.
* For details, see http://www.apache.org/licenses/LICENSE-2.0.
*/
/* 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: 0px;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: #000;
-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;
left: 0;
list-style: none;
}
.sidebar-nav li {
text-indent: 20px;
line-height: 40px;
}
.sidebar-nav li a {
display: block;
text-decoration: none;
color: #999999;
}
.sidebar-nav li a:hover {
text-decoration: none;
color: #fff;
background: rgba(255,255,255,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: #999999;
}
.sidebar-nav > .sidebar-brand a:hover {
color: #fff;
background: none;
}
#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;
}
}
Have you added any extra CSS to this design, or only working off of the Bootstrap default CSS file?
If the latter, just go into that file and find the classes that reference the navbar and the sidebar, then take note of the position and margin elements.
The navbar is likely going to have a 'fixed' position, which is obvious being that it is stuck to the top of the page no matter the scroll position.
You probably want the sidebar to scroll with the rest of the page though, so you'll want to set the margins for the top of the sidebar div to 0. Then you want to set the position of the sidebar-wrapper div to 'absolute' if it's not already, then add the following:
left:0;
that should do it, but if not (depending on the div hierarchy), try adding the following as well:
top:[px height of navbar];
All you should need to do is remove the margin from the bottom of the .navbar which is 20px by default.
.navbar.navbar-default {
margin-bottom: 0;
}
See working Snippet.
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
.navbar.navbar-default {
margin-bottom: 0;
}
.navbar-brand>img {
max-height: 100%;
height: 100%;
width: auto;
margin: 0 auto;
/* probably not needed anymore, but doesn't hurt */
-o-object-fit: contain;
object-fit: contain;
}
#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: 0px;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: #000;
-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;
left: 0;
list-style: none;
}
.sidebar-nav li {
text-indent: 20px;
line-height: 40px;
}
.sidebar-nav li a {
display: block;
text-decoration: none;
color: #999999;
}
.sidebar-nav li a:hover {
text-decoration: none;
color: #fff;
background: rgba(255, 255, 255, 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: #999999;
}
.sidebar-nav > .sidebar-brand a:hover {
color: #fff;
background: none;
}
#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;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<!-- <span class="sr-only">Toggle navigation</span> -->
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://disputebills.com">
<img src="http://disputebills.com/site/uploads/2015/10/dispute.png" alt="Dispute Bills">
</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home
</li>
<li>About
</li>
<li>Contact
</li>
</ul>
</div>
</div>
</nav>
</div>
<div id="wrapper">
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
TER
</a>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="panel panel-default">
<div class="panel-header">
<h1> TER</H1>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-3">
<div class="panel panel-default">
<div class="panel-body">
<img src="images.jpg" class="img-circle " alt="Cinque Terre" width="200" height="200">
</div>
Toggle Menu
</div>
</div>
<div class="col-lg-6 col-md-6">
</div>
<div class="col-lg-3 col-md-3">
<h1>TER</h1>
<div class="panel panel-default">
</div>
</div>
</div>
</div>
</div>
<div id="charts-wrapper">
<div class="container-fluid">
<div class="row">
<div col="col-lg-3">
haha
</div>
</div>
</div>
</div>
I have two problems with my navigation in twitter bootstrap.
the links jump out of the navigation when I re-size the browser window
and 2. the collapsed navigation is hidden behind the carousel.
I want all my links in the navigation to have the same width, because they get a border in mouse-over but because of that they jump out of the navigation and are hidden behind the carousel/slider when re-sized.
They collapse just fine when re-sized to 768px but everything above that jumps out of navigation. And the other thing is that when the navigation is collapsed it is half hidden behind the carousel/slider when opened.
<nav class="navbar navbar-inverse" role="navigation">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Test</a>
</div>
<div class="nav-collapse collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li class="span4">Home</li>
<li class="span4">Forschung</li>
<li class="span4">Fahrzeug</li>
<li class="span4">Team</li>
<li class="span4">Presse</li>
<li class="span4">Ziele</li>
<li class="span4">Karte</li>
<li class="span4">Jobs</li>
</ul>
</div>
</nav>
<div class="container">
<div id="this-carousel-id" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#this-carousel-id" data-slide-to="0" class="active"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/1200x480" alt="" />
<div class="carousel-caption"><h1>Mercedes Benz</h1></div>
</div>
</div>
<a class="carousel-control left" href="#this-carousel-id" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="carousel-control right" href="#this-carousel-id" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
</div>
and this is the css
.navbar {
height: 100px;
font-family: 'Oswald', sans-serif;
text-transform: uppercase;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
padding-right: 5%;
background-color: #000000 !important;
box-sizing: border-box;
}
.navbar-inverse .navbar-nav > li > a { color: #a2a2a2 !important }
.nav a:link,
a:visited {
line-height: 4em;
display: block;
height: 100px;
width: 120px;
text-align: center;
text-decoration: none;
}
.nav a:after {
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 1px;
background: #062d67;
content: '';
opacity: 0;
-webkit-transition: height 0.3s, opacity 0.3s, -webkit-transform 0.3s;
-moz-transition: height 0.3s, opacity 0.3s, -moz-transform 0.3s;
transition: height 0.3s, opacity 0.3s, transform 0.3s;
-webkit-transform: translateY(-10px);
-moz-transform: translateY(-10px);
transform: translateY(-10px);
}
.nav a:hover,
a:focus,
a:active {
height: 81px;
color: #ffffff !important;
background-color: #0d0d0d !important;
}
.nav a:hover:after,
.nav a:focus:after,
.nav a:active:after {
height: 18px;
opacity: 1;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
transform: translateY(0px);
}
Can anyone please point out what I did wrong?
You can't have 8 span4 elements in one row. the total sum of N in spanN must be 12 or below.
you can use span1in your case or no class on for <li> (list item) elements at all.