Unable to create another box in a column - html

Bootstrap Code: http://www.bootply.com/rKAlUVLSTA
I'm trying to create a box below the left sidebar but whatever I do, it is always in the white background zone. I do understand that if i add the "leftbar" class elsewhere, it will work but the width has to remain same as the logo background.
Screenshot:

Here is the solution: http://www.bootply.com/rw2brhxWy7 Basically what you had to do is split up the two into two separate columns within a parent column. I added a margin-top: 20px to be able to distinguish the two.
Relevant code below:
<div class="col-md-2">
<div class="col-md-12 leftbar" style="margin-top:50px;">
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-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>
<span class="visible-xs navbar-brand">Sidebar menu</span>
</div><!--/.navbar-header -->
<div class="navbar-collapse collapse sidebar-navbar-collapse">
<div class="text-center">
<p>John Doe</p>
<p>Points</p>
</div>
<ul class="nav navbar-nav sidebar-nav">
<li><span class="glyphicon glyphicon-dashboard"></span> Dashboard</li>
<li><span class="glyphicon glyphicon-flash"></span> Innovation</li>
<li class="active"><span class="glyphicon glyphicon-gift"></span> Redeem</li>
<li><span class="glyphicon glyphicon-cog"></span> Settings</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="col-md-12 leftbar" style="margin-top: 20px;">
I want to free myself from this white box and be in a new box instead.<p></p>
</div>
</div>
Edit: The problem was that now the column did not match the width of the green navbar div. You must remember that bootstrap's CSS will apply a padding of 20px left & right to every column. In order to fix this you should add a custom class to override that. Add the following class:
.noPadding {
padding-left: 0;
padding-right: 0;
}
Add this class to the following div:
<div class="col-md-2 noPadding">
<div class="col-md-12 leftbar" style="margin-top:50px;">
</div>
<div class="col-md-12 leftbar" style="margin-top: 20px;">
</div>
</div>
Edited Solution Bootply: http://www.bootply.com/tLCcdki4uP

Related

HTML Section Links Navigating to Wrong Location

I am new to Stack Overflow so please forgive me if this is a repeat question. I searched thoroughly, but could not figure this out.
I am building a zipline portfolio page using mostly Bootstrap v3.3.6 and cannot get my section links to navigate properly.
Here is a sample of my markup including the nav:
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<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>
<a class="navbar-brand" href="#">Matthew Shelbourn</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">Bio</li>
<li>Projects</li>
<li>Gallery</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
<!-- Body Section1 -->
<div>
<a name="bio"></a>
</div>
<div class="container" style="background-color:cadetblue;">
<div class="row">
<div class="col-xs-12 col-md-4">
<span><img id="profile-image" class="img-responsive pull-left" style="margin-top: 4.1%; margin-bottom:4.1%;" src="#"></span>
</div>
When I click on the link in my nav for "Bio" (or any of the other sections) it doesn't navigate to the top of the corresponding section. Instead, it navigates to an area about 1/3 of the way down from the top of the section.
This same issue happens with every section link I have. I'm sure it's something trivial, but what am I doing wrong? Thanks!

Bootstrap Nav Container Fluid Center li

How do I center list items on a container-fluid navigation? I have been jsfiddling with this for hours. I havent gotten anything that works properly. Looked over a ton of websites for answers.
<nav class="navbar navbar-info navbar-fixed-top">
<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="hidden-xs" href="#">
<div class="logo-container">
<div><img src="assets/img/logo-header-optimized.svg" alt="" height="52" style="margin:10px 0px 10px 0px"></div>
</div>
</a> <a class="visible-xs navbar-brand"><img src="assets/img/phone-logo-header-optimized.svg" alt="" height="22"></a> </div>
<div>
<ul class="hidden-xs nav navbar-nav navbar-right" style="margin-top:10px">
<li>
<button type="button" class="btn btn-inverse navbar-btn btn-raised" onclick="window.open('')"><strong> BOOK NOW </strong></button>
</li>
</ul>
</div>
</div>
<div class="container-fluid">
<div class="navbar-header">
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li> Introduction <i class="material-icons"></i>
</li>
<li> Amenities <i class="material-icons"></i>
</li>
<li> Hospitality <i class="material-icons"></i>
</li>
<li> Information <i class="material-icons"></i>
</li>
</ul>
</div>
</div>
</div>
First: The div <div class="navbar-header"> should have a "witdh:100%".
Second: between insert a div with this style="width: 60%; margin: 0 auto;"
The width: 60% depending of elements
I tried the solution by Julian and it lowers the button on the left and I dont think he wants that. The two solutions that I have are to add one of 2 css styles.
First one .navbar-header {padding: 0 300px;} this will center the list items but will also move the image with it
Second one .navbar-nav {padding: 0 300px;} this will center the list items but will also bring the button closer to the middle but still in the same row as the image.
If you want to dig deeper, I recommend reading this

Twitter Bootstrap Section Scrolling Issue

On my website in development, I have a link in my navbar that should bring me to the section with the id About, however It seems to ignore the positioning of my navbar, thus throwing off the position a tight bit. Any help in resolving this issue would be appreciated
Visualization of the Problem
Before clicking: http://imgur.com/akrheOX
After clicking: http://imgur.com/zlmL6GQ
Navbar Code
<nav class="navbar navbar-default navbar-fixed-top">
<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 page-scroll" rel="home" href="#" title="Virtual Currency Converter"><img style="max-width:350px; margin-top: -20px;"
src="./assets/img/vicuco_brand.png">
</a>
</div>
<div id="navbar" class="navbar-collapse collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a class="page-scroll" href="#About">About</a>
</li>
<li><span class="glyphicon glyphicon-cog gi-2x"></span></li>
</ul>
</div><!-- nav-collapse -->
</div>
</nav>
About Section Code
<section class="bg-primary" id="About">
<div class="row">
<div class="container">
<div class="row">
<div class=" text-center">
<h2 class="section-heading" id="AboutHeader">About Us</h2>
<div id="AboutSubtitle">
<p>
Vicuco stands for <strong>Virtual Currency Converter</strong>. <br><br>
Indeed, it is our goal to allow for simple and easy conversion <br>
of the virtual currencies among themselves, as well as to foreign currencies. <br><br>
We are an aggregator. That means we aggregate virtual currency <br>
trading data from all major virtual currency exchanges, in order <br>
to show you a near real-time conversion rate. <br><br>
We will send you in the right direction, if you need to buy, sell, or <br>
exchange virtual currency.<br><br>
</p>
<p>
Follow us on <a class="btn btn-social-icon btn-twitter" href="https://twitter.com/vicucodotcom">
<span class="fa fa-twitter fa-2x"></span></a> and check out our
<strong>blog</strong>
for our latest developments!
</p>
</div>
</div>
</div>
</div>
<img src="assets/img/cloud.png" id="cloud" width="25%" height="100%">
</div>
</section>
You are using a fixed header, so it's location and size will be ignored by the other page contents. One method to fix this is to use a little script that does the following:
Detects the navbar height
On navabar item click - scroll the page but offset it from the top of the viewport
The offset is determined by the navbar height we just detected.
You can see it added below.
I say 'one method' because there is an alternate approach where the anchor points can be offset (see here)
$(document).ready(function() {
$(".navbar ul li a[href^='#']").on('click', function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: $(this.hash).offset().top - $('.navbar').height()
}, 600);
});
});
#one, #two, #three {
height: 1000px;
}
#one {
background: pink;
}
#two {
background: salmon;
}
#three {
background: lightsalmon;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http:////maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<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="#">Offset Scroll</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Section one</li>
<li>Section two</li>
<li>Section three</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
<div class="container">
<section id="one"></section>
<section id="two"></section>
<section id="three"></section>
</div>
</body>

Bootstrap slider off-canvas is not working perfectly in mobile chrome browser

i am using bootstrap v3.2.0, creating a theme. Bootstrap was working fine in system browser but as it was almost done, in testing mode i came to know that slider is not working fine on the real devices.
my menu is on left and it has toggle button to show the left menu in small screen, but on mobile or tabs it appears and pushes the body to right but the body does not slide it-self which results its size get small and adjust in the screen. it should slide to right.
my HTML is
<div class="navbar navbar-default" role="navigation" id="MainHeader">
<div class="navbar-header">
<div class="clear"></div>
<div class="logo left">
ABC Company
</div>
<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>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav header-float">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div><!-- /.nav-collapse -->
</div>
<!-- /Header -->
<div class="" style="">
<div class="row row-offcanvas row-offcanvas-left">
<div class="col-xs-6 col-sm-3 col-md-3 sidebar-offcanvas" id="MainMenu" role="navigation" style="margin-right: -15px;">
<div class="" id="Leftmenu">
<ul id="Leftmenu">
<li class="active">home</li>
<li>Link</li>
<li>Link</li>
</ul>
</div>
</div>
<div id="MainGrid" class="col-xs-12 col-sm-9 col-md-9 ">
<div class="row">
<p class="pull-left visible-xs">
<button type="button" class="panel-button btn- xs" data-toggle="offcanvas">
Togglenav
</button>
</p>
</div>
<div class="row" id="MainContents">
Body...
</div>
</div>
</div>
</div><!--/row-->
css and js files are not attached,Bootstrap version is mentioned above.

Twitter Bootstrap navbar float right moves div to new line

Hello I'm trying to create a section on the right of the navbar. I used the div class navbar-right which should float the div to the right, but I am getting a new line instead.
See below for code & thanks!
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<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>
<a class="navbar-brand" href="index.php">xxx</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
<div class="navbar-right">
<p>
<b> '.$username.' </b> | Access Level: '.$level.' | <a href=logout.php>Logout</a>
</p>
</div>
</div>
</div>
In order to be placed at the top level of nav-bar, the contents must be placed inside of a div with the class: navbar-header
So instead of declaring the logout link inside of the div:
<div class="navbar-right">
Use the following classes instead:
<div class="navbar-header pull-right">
Since you'll want the Brand to pull-left, you can place two navbar-header divs right next to each other at the very top and have one pull to each direction. Like this:
<div class="navbar-header pull-left">
<a class="navbar-brand" href="index.php">xxx</a>
</div>
<div class="navbar-header pull-right">
<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>
<p class="navbar-text">
<b> '.$username.' </b>
Logout
</p>
</div>
jsFiddle
Expanded
Collapsed
Update:
As per Ram's comment, in order to not have the pull down menu not overlap on a small screen, you'll have to clear the left float like this:
.navbar-collapse.in,
.navbar-collapse.collapsing {
clear: left;
}
Instead of,
<div class="navbar-right">
<p>
<b> '.$username.' </b> | Access Level: '.$level.' | <a href=logout.php>Logout</a>
</p>
</div>
Use,
<p class="pull-right">
<b> '.$username.' </b> | Access Level: '.$level.' | <a href=logout.php>Logout</a>
</p>