Making the content adjust when navigation sidebar is collapsed Bootstrap - html

Hi I am new to CSS and bootstrap. I have a button which will make the navigation sidebar collapsible and all i need is to make the content of the page to float to the left when the navigation sidebar is collapsed and shrink if the navigation sidebar is expanded.
Kindly suggest me a solution :(
below is my sample code
<nav class="navbar navbar-default navbar-fixed-top" role="navigation" >
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header ">
<button type="button" class="navbar-toggle visible-lg" data-toggle="collapse" data-target="#navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="collapse navbar-default navbar-collapse" >
<div class="pull-left" id="navbar-ex1-collapse">
<ul class="nav navbar-default navbar-nav side-nav">
<li class="dropdown">
<i class="fa fa-user"></i> My Profile <b class="caret"></b>
<ul class="dropdown-menu">
<li ><a class="dropdown-color" href="#" style="background:rgba(59, 89, 152, 0.28);" ><i class="fa fa-user"></i> View Profile</a></li>
<li><a class="dropdown-color" href="#" style="background:rgba(59, 89, 152, 0.28);"><i class="fa fa-edit"></i> Edit Profile</a></li>
</ul>
</li>
<li><i class="fa fa-dashboard"></i> Dashboard</li>
<li class="dropdown">
<i class="fa fa-desktop"></i> Deployment <b class="caret"></b>
<ul class="dropdown-menu">
<li><i class="fa fa-edit"></i> Deployment Parameter</li>
<li><i class="fa fa-bar-chart-o"></i> Package Deployment</li>
<li><i class="fa fa-bar-chart-o"></i> Release Deployment</li>
</ul>
</li>
</ul>
</div>
<ul class="nav navbar-nav navbar-right navbar-user">
<li class="dropdown user-dropdown">
<i class="fa fa-user"></i> Username <b class="caret"></b>
<ul class="dropdown-menu">
<li><i class="fa fa-user"></i> View Profile</li>
<li><i class="fa fa-gear"></i> Edit Profile</li>
<li class="divider"></li>
<li><i class="fa fa-power-off"></i> Log Out</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
<div class="auto-adjust" id="page-wrapper">
//table goes here
</div>
below is my css class which i wrote for adjusting the content
CSS:
.auto-adjust{
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
margin:0;
float:left;
}

In Twitters Less code the point that the navbar collapse has been set by #grid-float-breakpoint (set to 768px) by default. Now you can use CSS media queries to only apply your code before that point:
less
#media (max-width: (#grid-float-breakpoint - 1)) {
padding-right: 15px;
padding-left: 15px;
margin: 0 auto;
float:left;
}
CSS output:
#media (max-width: 767px) {
padding-right: 15px;
padding-left: 15px;
margin: 0 auto;
float: left;
}
Notice that you probably better can use Bootstrap's grid, see http://getbootstrap.com/css/#grid-media-queries. The xs grid will be applied when the green width is smaller than 768 pixels too.
Try the following code:
<div class="row">
<div class="col-xs-12 col-sm-6">//table goes here</div>
<div class="col-xs-12 col-sm-6">//other content</div>
</div>

Related

To change the default bootstrap css values with less

I'm doing a site with HTML5 andbootstrap-lessnothing works normally but I needed to change some colors in the navbar menu and I know I can do this throughvariables.less inside this file I navigate to the menus where I copy all the code related to the menu that I want to edit and paste in my .less file but it does not work I do not want to have to use! important to change the menu being that I know I can do this by only variables in the less that comes in the bootsrap this is theless code of the menu
LESS:
#navbar-default-color: #fff;
#navbar-default-bg: #f8f8f8;
#navbar-default-border: darken(#navbar-default-bg, 6.5%);
//* Navbar links*/
#navbar-default-link-color: #fff;
#navbar-default-link-hover-color: #fff;
#navbar-default-link-hover-bg: transparent;
#navbar-default-link-active-color: #fff;
#navbar-default-link-active-bg: darken(#navbar-default-bg, 6.5%);
#navbar-default-link-disabled-color: #fff;
#navbar-default-link-disabled-bg: transparent;
/* Navbar brand label*/
#navbar-default-brand-color: #navbar-default-link-color;
#navbar-default-brand-hover-color: darken(#navbar-default-brand-color, 10%);
#navbar-default-brand-hover-bg: transparent;
/* Navbar toggle*/
#navbar-default-toggle-hover-bg: #fff;
#navbar-default-toggle-icon-bar-bg: #fff;
#navbar-default-toggle-border-color: #fff;
even though I change the values it does not change on my site notice that I left everything white to do a test and my site does not change:
this is my menu:
<nav class="navbar navbar-default">
<div class="container text-center">
<div class="row">
<div class="box-menu">
<div class="col-md-3">
<img src="assets/images/logo-santa-clara-eco.png" class="img-responsive" alt="Santa Clara EcoResort" />
</div>
<div class="col-md-6 hidden-xs hidden-sm">
<ul class="list-unstyled list-inline contact-info">
<li class="list"><i class="fa fa-map-marker" aria-hidden="true"></i>Rod SP 215 Km 197 - Dourado - SP</li>
<li class="list"><i class="fa fa-phone" aria-hidden="true"></i>+55 (16) 3345 4004</li>
<li class="list"><i class="fa fa-envelope" aria-hidden="true"></i>Contato</li>
</ul>
</div>
<div class="col-md-3 hidden-xs hidden-sm">
<img src="assets/images/logo_top.png" class="img-responsive logos-inline" alt="Tripadvisor L'OCITANE ABR" />
</div>
</div>
</div>
<div class="row">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav list-nav-menu">
<li><i class="fa fa-home" aria-hidden="true"></i></li>
<li>resort</li>
<li><a href="http://santaclaraecoresort.com.br/acomodacoes.php" id="question" >acomodações</a></li>
<li>gastronomia</li>
<li>atividades</li>
<li>SPA </li>
<li>eventos</li>
<li>monitoria</li>
<li>pacotes</li>
<li>programação</li>
<li class="dropdown">
Contato <b class="caret"></b>
<ul class="dropdown-menu">
<li>Localização</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right list-inline social-networks hidden-xs hidden-sm">
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-instagram" aria-hidden="true"></i></li>
<li><i class="fa fa-youtube" aria-hidden="true"></i></li>
<li><i class="fa fa-tripadvisor" aria-hidden="true"></i></li>
</ul>
</div>
</div>
</div>
</nav>
I'm importing everything normal bootstrap``css andjs together with jquery and I'm doing# import right away
<link rel="stylesheet" href="assets/vendor/bootstrap/dist/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="assets/vendor/bootstrap/dist/js/bootstrap.min.js"></script>
my app.less file with the import:
#import "../vendor/bootstrap/less/bootstrap.less";
#import "app.css";
image of my variables with the colors I need to change, I copied the variables from the variables.less file and added it to myapp.less I changed the colors they appear on the console but they do not overwrite.
my less file with the color changes (remembering that this is a copy of thevariables.less file)

How do I fix my lists so I don't have to toggle twice before the icon updates?

Basically what happens is when I load my page and then drop down either my outer collapsible menu (the .admin) or the nested collapsible menu (.unitsofstudy), it does not update the glyphicon I have set using the :after selector unless I toggle it twice.
Would anyone be able to take a look and see if they can spot where I have screwed this up; I have been at this for a few hours now trying to fix but with no success. If any more info is needed let me know.
HTML:
<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
<ul class="nav menu" id="navmenu-sidebar">
<!-- Admin dropdown -->
<li>
<a class="admin" data-toggle="collapse" href="#admin"><i class="fa fa-tasks" style="margin-right: 16px;"></i>Admin</a>
<ul id="admin" class="nav collapse">
<li>
<a class="unitsofstudy" data-toggle="collapse" href="#unitsofstudy"> <i class="fa fa-book" style="margin-right: 12px;"></i>Units of Study</a>
<ul id="unitsofstudy" class="nav collapse">
<li>
<i class="fa fa-book" style="margin-right: 8px;"></i> View Units
</li>
<li>
<i class="fa fa-plus" style="margin-right: 10px;"></i> Create Unit Offerings
</li>
<li>
<i class="fa fa-plus" style="margin-right: 10px;"></i> Register Units
</li>
<li>
<i class="fa fa-plus" style="margin-right: 10px;"></i> Register Semesters
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
My CSS:
.admin:after, .unitsofstudy:after {
font-family: 'Glyphicons Halflings';
content: "\e114";
float: right;
color: grey;
}
.admin.collapsed:after, .unitsofstudy.collapsed:after {
content: "\e080";
}
You need to give your anchors an initial class of .collapsed
<li>
<a class="admin collapsed" data-toggle="collapse" href="#admin">
<i class="fa fa-tasks" style="margin-right: 16px;"></i>Admin
</a>
</li>
So class both admin and unitsofstudy to let bootstrap know the initial state of the menu is collapsed
Working example
http://codepen.io/jcoulterdesign/pen/6443069430f54e0b635e726c2cb9da02

Bootstrap Centering Content within a Div

Basically I want my drop down boxes to be horizontally aligned in the center of the <div>. Currently they are in a column and inside a <div> which has displayed them vertically, by default and has pushed the content to the left of the <div>.
I'm using the latest version of bootstrap and only have CSS to pad the header and to set it as transparent!
<div class=" navbar transparent navbar-default navbar-fixed-top" role="navigation"> <!--HEADER-->
<div class="container-fluid header"> <!--CONTAINER- Needs to be inset slightly-->
<div class="row">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!--First NavBar Colum - Logo is Located Here-->
<div class=" navbar-collapse collapse">
<div class="col-sm-4 ">
</div>
<!--Second NavBar Colum - Centered Horizontal Navigation Links are Located Here-->
<div class="col-sm-4 ">
<ul class="nav navbar-nav navbar-left">
<ul class="dropdown">
<i class="fa fa-circle-o"></i>
PLAY
<ul class="dropdown-menu">
<li class="divider"></li>
<li>Public Teatimes</li>
<li>Member Teatimes</li>
<li>Course Tour</li>
<li>Rates and Ratings</li>
<li>Outings</li>
</ul>
</ul>
<ul class="dropdown">
<i class="fa fa-circle-o"></i>
CLUB
<ul class="dropdown-menu">
<li class="divider"></li>
<li>Membership</li>
<li>Calender</li>
<li>Lessons and Shop</li>
<li>Bar and Food</li>
</ul>
</ul>
<ul>
<i class="fa fa-circle-o"></i>
CONTACT
</ul>
</ul>
</div>
<!--Third NavBar Colum - Social Media Icons are Located Here-->
<div class="col-sm-4">
<i class="fa fa-facebook-square fa-3x"></i>
<i class="fa fa-twitter-square fa-3x"></i>
<i class="fa fa-instagram fa-3x"></i>
</div>
</div> <!--/ .nav-collapse-->
</div>
</div>
</div>
In .navbar-nav, .navbar-left there is float:left . SO, you have remove that first float:none. Then on parent col-sm-4 you can add .text-center.
Try something like this
.navbar-nav{
width:250px;
margin:0 auto;
float:none;
text-align:center;
}
And remove float from <li> if you use.
#media (min-width: 768px)
.navbar-nav {
text-align: center;}

Bootstrap NavBar not aligned, especially in mobile view

My navbar seems to go out of whack. It's especially evident when I view the site on my mobile device, or just shrink my desktop window.
Below is a link to my site along with the code. I would love for my name to fit between my projects tap on the left and my e-mail and twitter icons on the right. Thank you for your help and time.
http://jocatcreative.com/
(trying to get past stack socials 2 link limit...
imugr dot com/0s4iJyr
imgur dot com/vqjiyEd)
(Edited to include screenshots)
<div class="navbar navbar-default">
<div class="container">
<div class="Heading Tag" align="center"><h2>Jovan S Hernandez</h2></div>
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target="#example-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="example-navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Projects <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>JoCat Creative Media</li>
<li>Gesaffelstein Landing</li>
<li>Monthly Resolutions</li>
<li class="divider"></li>
<li>Home</li>
<li class="divider"></li>
</ul>
</li>
</ul>
<ul class="pull-right">
<i class="fa fa-envelope-o"></i> Email Me
<i class="fa fa-twitter"></i> Twitter
</ul>
</div><!-- .container -->
</div><!-- .navbar -->
DEMO: https://jsbin.com/qufelu/1/
https://jsbin.com/qufelu/1/edit?html,css,output
You were using some incorrect classes, missing tags (on the right aligned stuff), unclosed tag (collapse), and were using an outdated attribute from ancient history ( align="center") Also, you don't need to wrap the name inside a div.
CSS
.custom-navbar {
background: transparent;
border: 0px;
}
#media (max-width:767px) {
.custom-navbar .name {
font-size: 20px;
float: left;
margin: 0;
padding: 15px 0 15px 15px;
}
.custom-navbar .navbar-toggle {
margin: 10px 15px 0 0;
float: right;
}
}
#media (min-width:768px) {
.custom-navbar .navbar-header {
width: 100%;
margin: 0;
}
.custom-navbar .name {
text-align: center;
float: none;
}
}
HTML:
<div class="navbar navbar-default custom-navbar">
<div class="container-fluid">
<div class="navbar-header">
<h2 class="name">Jovan S Hernandez</h2>
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target="#navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="navbar-right nav navbar-nav">
<li><i class="fa fa-envelope-o"></i> Email Me</li>
<li><i class="fa fa-twitter"></i> Twitter</li>
</ul>
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Projects <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>JoCat Creative Media</li>
<li>Gesaffelstein Landing</li>
<li>Monthly Resolutions</li>
<li class="divider"></li>
<li>Home</li>
<li class="divider"></li>
</ul>
</li>
</ul>
</div>
<!-- .navbar-collapse -->
</div>
<!-- .container -->
</div>
<!-- .navbar -->

Bootstrap 3 off-canvas how to

So i just don't get it.
I've looked for some good examples for off canvas in bootstrap 3 but i just don't get it. I have already set up my navigation but dun know how this off canvas works.
When i use a mobile device i want my toggled navigation to slide in from the right to the left over the whole browser screen with an "X" on the upper left corner to close this one again. So it's like : User clicks on the toggled Navigation -> Navigtion slides in from the right to the left over the whole screen -> Navigation is listed there -> click on an menu point and close the navigation with sliding out from left to right.
Anyone got any ideas ???? Really need help
My Navigation looks like this atm :
<header>
<div class="container-header hidden-xs">
<!-- Navigation -->
<div class="first-nav">
<form class="navbar-search">
<input type="text" class="search-query span3" placeholder="search">
</form>
<ul class="social-buttons" id="home">
<li><i class="fa fa-youtube fa-lg"></i></li>
<li><i class="fa fa-twitter fa-lg"></i></li>
<li><i class="fa fa-xing fa-lg"></i></li>
<li><i class="fa fa-rss fa-lg"></i></li>
</ul>
<a class="navbar-lang" href="#" title="English">Eng</a>
</div>
</div>
<div id="nav">
<div class="navbar navbar-default navbar-static" role="navigation">
<div class="second-nav">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="nav-logo">
<img src="images/Logo_nav.png" alt="DnD">
</div>
<div class="navbar-collapse collapse">
<ul class="mainnav nav navbar-nav">
<li>Home</li>
<li>Leistungen</li>
<li>Über uns</li>
<li>Team</li>
<li class="dropdown">
Aktuelles<b class="caret"></b>
<ul class="dropdown-menu">
<li>Alle Artikel</li>
</ul>
</li>
<li>Kunden</li>
<li class="dropdown">
Jobs<b class="caret"></b>
<ul class="dropdown-menu">
<li>Alle Jobs</li>
</ul>
</li>
<li>Kontakt</li>
</ul>
</div>
</div>
</div>
</div>
</header>
Correct me if I am wrong, but something like below should work:
#media screen and (max-width: 767px) {
.row-offcanvas-right.active {
right: calc(100% + 30px); /*30px to get row margin back (-15px + (-15px))*/
}
}