How to to make bootstrap navbar smaller in width? - html

I want to make bootstrap navbar smaller and keep it right but small issue here i have some data dynamically loading at right side of grid that is overlapped by navbar so i want to keep navbar offset around 3 columns from right,so I added css class container-panel to make width smaller and to keep it to right i have margin-left.But on different pixels it breaks and navbar is overlapped on other elements. Is there any fix in bootstrap to achieve this task ?
main.html
<div class="col-md-10">
<nav class="navbar navbar-default container-panel">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1" style="z-index:10;">
<ul class="nav navbar-nav pull-right">
<li class="dropdown">
<span class="glyphicon glyphicon-file"></span><span class="caret"></span>
<ul class="dropdown-menu">
<li><span ng-click="createXml()">Create new BPMN Diagram</span></li>
</ul>
</li>
<li><span class="glyphicon glyphicon-folder-open"></span></li>
</ul>
</div>
</div>
</nav>
</div>
main.css
.navbar.container-panel {
width:554px;
margin-left: 760px;
}

Use a variable width, like vw or % to adapt the width relative to the screen width. You may have to tweak the vw or % at smaller breakpoints as to not cut off your navbar content.
.navbar.container-panel {
width:60vw;
margin-left: 760px;
}
or
.navbar.container-panel {
width:60%;
margin-left: 760px;
}

Related

Make Image Link Container Height

I have a website running with Bootstrap. I'm trying to get an image to match its container's height (it's huge right now). I've seen make an image fit its container by setting the image height to the containers height but it's not working. My best guess as to why is because it's inside a link:
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="/">K7DXS</a>-->
Here's the image:
<a class-"navbar-brand" class="k7dxslogo" href="/"><img src="/k7dxsblink.gif" class="k7dxslogo" alt="K7DXS" /></a>
The rest of the code:
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Linux</li>
<li>Ham Radio</li>
<li>Contact</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Partner Sites</li>
<li>External Links</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
My relevant style.css:
.k7dxslogo {
height: 100%;
}
Why isn't it working, and how do I fix it?
EDIT: To be clear, I do NOT want to set a definite height for anything. To do so would make it so that the site is not responsive.
Add "img-responsive" class to your HTML img tag.
Set a defined height for navbar-brand

I have a container-fluid that isn't extended across the whole screen even though it should be

I can't seem to figure out why this is.
My code is as follows:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<div class="container-fluid">
<div style="text-align:center"><a href="http://www.leagueofassassins.co.uk">
<img class="banner" src="../images/logos/Logo%20for%20LoA.png"></a>
</div>
<!--Navbar Begin-->
<nav class="navbar-static-top navbar-inverse navbar-inner navbar-custom" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="#"></a>-->
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Home</li>
<li>Info</li>
<li>Roster</li>
<li>WarcraftLogs</li>
<li class="active">Apply</li>
</ul>
</div>
</div>
</nav>
<!--Navbar End-->
For some reason, it leaves a big area at the right hand side when vertical but works when my phone is horizontal. I have included pictures below. Any help would be appreicated. I want it to be full screen width.
Ignore the well at the bottom with the overflowing text, please. That's not the problem.
See http://www.leagueofassassins.co.uk/apply/
It looks like your "main-pane" cals got 60% width, try removing it and it should work fine.
CSS Class
.main-pane {
margin-top: 1%;
margin-bottom: 5%;
width: 60%; // remove this line
height: 100%;
}
It turns out that I'd accidentally missed some padding on either side of .container-custom and the bottom content was spilling over causing the page to need to be widened. It works now. Thanks.

Body not dropping below Bootstrap Navigation

Having CSS/HTML issues with Bootstrap. For some reason it seems the navigation is not pushing down the aspects of the HTML that follows. See https://jsfiddle.net/xaazf6u2/
<div id="topNavigation">
<nav class="navbar navbar-inverse 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="#">BCF</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li class="dropdown">History <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>FGT</li>
<li>BB</li>
</ul>
</li>
</ul>
<ul id="login" class="nav navbar-nav navbar-right"></ul>
</div><!--/.nav-collapse -->
</div>
</nav>
</div>
<div id="pageContent" class="container">
<div class="jumbotron">
<h1>Welcome</h1>
<p>Use the form below to upload an order feed. Once uploaded, FedEx shipping will be purchased, labels and packing slip generated for us. Use the navigation above to access previously generated files.</p>
</div>
</div>
From the examples you can see that the jumbotron should have some space below the navigation http://getbootstrap.com/examples/theme/
When you used the fixed navbar Bootstrap recommends you add padding to your body to prevent this problem. So in your CSS you need to add
body { padding-top: 70px; }
The navbar is position:fixed so that it stays on the screen as you scroll. Elements with fixed position don't affect layout of other elements, so you'll need to manually set margin or padding on them.
See the Bootstrap documentation for notes on this.
Body padding required
The fixed navbar will overlay your other content, unless you add padding to the bottom of the <body>. Try out your own values or use our snippet below. Tip: By default, the navbar is 50px high.
Copy
body { padding-bottom: 70px; }
Make sure to include this after the core Bootstrap CSS.
The class "navbar-fixed-top" means that the content is scrollable and goes under the navbar.
Add a margin-top to the content if you want to keep this feature or remove the "navbar-fixed-top" class if you don't.
Navigation bar is fixed to the top by default you can change that by removing the class 'navbar-fixed-top'.

Add a quote Button to bootstrap Navigation Bar and Make it stay Permanently?

I would like:
1. The Free Quote Button to be forced right
2. At small screensizes I would like free quote button to remain to the right of the (icon bar button [mobile menu])
3. I don't want the navigation bar to take up an extra line when at smaller screen size
Fiddle:
http://jsfiddle.net/z7V4F/
HTML:
<!-- Nav bar -->
<nav class="navbar navbar-inverse navbar-fixed-top navi-style" role="navigation">
<!-- quote button-->
<!--Free Quote-->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button> <a class="navbar-brand menulogo" href="#">
My Site + Logo Makes This Long
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<!--<li class="active">Home</li>-->
<li class="dropdown"> Info Tab<b class="caret"></b>
<ul class="dropdown-menu">
<li>Overview
</li>
</ul>
</li>
<li class="dropdown"> contact Tab<b class="caret"></b>
<ul class="dropdown-menu">
<li>Overview
</li>
</ul>
</li>
<li class="dropdown"> about Tab<b class="caret"></b>
<ul class="dropdown-menu">
<li>Overview
</li>
</ul>
</li>
<li class="dropdown"> More Tab<b class="caret"></b>
<ul class="dropdown-menu">
<li>Overview
</li>
</ul>
</li>
<div class="navbar-right"> Free Quote
</div>
</ul>
</div>
</nav>
1. The Free Quote Button to be forced right
I would use position: absolute; here to avoid excessive juggling with margins and paddings. This way it will always stay on the same line. This will look worse if your navbar-header and nav items are wider though than in your fiddle.
.navbar-right {
position: absolute;
right: 0;
}
2. At small screensizes I would like free quote button to remain to the right of the (icon bar button [mobile menu])
Put another <button> above the navbar-toggle with pull-right and visible-xs classes. This will place the button on the right side of the navbar-toggle and make it visible only on XS screen sizes.
<div class="pull-right visible-xs free-quote">Free Quote</div>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand menulogo" href="#">
My Site + Logo Makes This Long
</a>
Give hidden-xs class to the other button so It won't show up in XS screen sizes. (example in answer to number 3)
3. I don't want the navigation bar to take up an extra line when at smaller screen size
You can show smaller button on SM screen sizes to avoid the need for navbar to expand on two lines like this (by need I mean otherwise it is more likely that navigation items and the button will overlap each other):
<div class="navbar-right hidden-xs free-quote">
Free Quote
Free Quote
</div>
I would suggest that you show logo or text only in navbar-brand on XS screen sizes so that they won't jump to their own line when the screen size is only e.g. 320px wide.
4. Extra: Make it look nice
Give some padding and margin to those buttons to align them nicely.
.free-quote {
padding: 9px 5px 9px 0
}
.free-quote > .btn-xs {
margin-top: 4px;
}
Here is the fiddle: http://jsfiddle.net/z7V4F/3/
You need to have two buttons.
One within the navbar-header and one outside.
The button within the navbar-header should only be visible at the extra small screens, as everything not within navbar-header is hidden at xs.
Everything within navbar-collapse will be hidden (become a mobile menu) at extra small sizes.
Html:
<div class="menuquote navbar-right hidden-xs"> Free Quote
</div>
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button> <a class="navbar-brand menulogo" href="#">
My Site + Logo Makes This Long
</a>
<div class="menuquote navbar-right pull-right hidden-sm hidden-md hidden-lg"> Free Quote
</div>
</div>
http://jsfiddle.net/4nmzh/
To get the button to be forced left and to appear to the right of the mobile menu toggle, put this div:
<div class="navbar-right">
Free Quote
</div>
just before the navbar-header and change navbar-right to pull-right
This takes the button out of the navbar formatting and forces the button to the right as pull-right is bootstrap's float: right class.
To stop your navbar going on to two lines at very small screen sizes your options are:
Set a min-width on your <nav class="navbar">
.navbar {
min-width: 470px;
}
(see this demo)
Shrinking the size of your logo/text in your <a class="navbar-brand"> at small screen sizes using media queries e.g.:
#media (max-width: 500px) {
navbar-brand {
...
}
}
When your navbar is larger I have reduced the padding on the list items to make them stay on one line:
ul.nav li a {
padding-left: 8px;
padding-right: 8px;
}
This Demo should at least give you a starting point.
Hi you can move free quotes outside the tag and add absolute position to it
look at the fiddle: http://jsfiddle.net/z7V4F/4/
As I said i moved div containing free quotes outside navbar-collapse and added next css.
.custum-free-quotes{
position:absolute;
right:0;
top: 0;
}
.navbar{
position relative;
}

Bootstrap collapsible button pushing brand element down

I'm using the navbar example:
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="#">Create Single Page</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Link</li>
<li>Link</li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
But when the screen enters 261px in width, the collapsible button pushes down the title of the site, making things awkward looking. I tried wrapping the "a tag" with a column but just puts a word break.
261px is extremely narrow -- very few modern devices are so low-resolution, and users generally do not expect a site's content to be usable or readable at this size.
So I'd recommend either ignoring the issue entirely (like Bootstrap itself does) or setting a minimum width in CSS like this (depending on the rest of your markup and styles, you may want to change body to a selector for your outermost container):
body {
min-width: 280px;
}
Which will add horizontal scrollbars when the page width goes below 280px, instead of attempting to be responsive to so far down a size.
If you absolutely must support a view this narrow, you could add new media queries to the CSS like:
#media screen and (max-width: 270px) {
// tiny styles for your site logo here, e.g.:
.navbar-brand {
font-size: 0.5em;
}
}
...to size down the title as needed.