Angular Bootstrap Navbar component position - html

I have an angular page where I want a fixed nav bar on top. The title of the page on the left, some buttons in the middle, and a dropdown on the right. I'm using bootstrap and ui-bootstrap and I've got somewhat of a navbar going but I just can't get the dropdown to go to the right. It just stays in the middle no matter what I try. Here's a plunker reproducing my problem. I've tried text-align: right; and float:right; but nothing works!
Any idea what I'm doing wrong here? Or is there a good example that does what I want?

Try reversing the order of your center div and right div (order matters when floating) like so:
<nav class="navbar navbar-default navbar-fixed-top navbar-shrink">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<a class="navbar-brand page-scroll">Test</a>
</div>
<div class="navbar-header page-scroll navbar-right pull-right">
<div class="btn-group" uib-dropdown>
<button id="btn-append-to-single-button" type="button" class="btn btn-primary" uib-dropdown-toggle>
Dropdown <span class="caret"></span>
</button>
<ul class="dropdown-menu"
uib-dropdown-menu role="menu"
aria-labelledby="btn-append-to-single-button">
<li role="menuitem">Action</li>
<li role="menuitem">Another action</li>
<li role="menuitem">Something else here</li>
</ul>
</div>
</div>
<div class="float-center btn-group form-group row"
data-toggle="buttons">
<label ng-repeat="foo in ctrl.foos" class="btn btn-primary">
<input type="radio"
name="foo"> {{foo}}
</label>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
Also, you probably want to give the parent element of your navbar-brand the float: left property so it doesn't span the entire width. And if you want to keep using relative positioning for your center element, you'll need to play around with the values. Left: -15% worked for me with the above changes.

What I can see from the plunker is the css below breaks the position of the dropdown list :
.float-center {
float: right;
left: -35%;
margin: 4px;
}
Two simple solutions could be done:
1. switch the position of the dropdonw button and the middle buttons, forked link here: https://plnkr.co/edit/HAAKWziKM3o6uBE6uZtq?p=preview
change the float from right to left and modify the value of left
Hope this can help you :)

Related

bootstrap 4 change navbar height causing navbar items to not be vertically centered

I have a bootstrap 4 navbar like this:
<nav class="navbar navbar-light bg-faded navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<!-- Toggle Button -->
<button type="button" class="navbar-toggler hidden-md-up"
data-toggle="collapse"
data-target="#nav-content"
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="#">THE VEGAN REPOSITORY</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-toggleable-md" id="nav-content">
<ul class="nav navbar-nav pull-xs-right">
<li class="nav-item">
<a class="nav-link" href="#home_page_footer">
<h5 class=" nav-item clickable white-text medium-text
right-text">
ABOUT
</h5>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#home_page_footer">
<h5 class=" nav-item clickable white-text medium-text
right-text">
BLOG
</h5>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://www.w3schools.com">
<h5 class=" nav-item clickable white-text medium-text
right-text">
LOGIN
</h5>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://www.w3schools.com">
<h5 id=" sign-in-button" class="nav-item clickable
medium-text right-text">
SIGN UP FREE
</h5>
</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<nav class="navbar navbar-light bg-faded">
<!-- Toggle Button -->
<button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#nav-content">
</button>
</nav>
I'd like to change the height of the navbar, but when I do, the links are no longer vertically centred.
70px
I have tried line-height, and flexbox options such as
nav {
background-color: $brand-red;
height:70px;
display: flex;
align-items: center;
}
which does:
my only css used for the whole navbar is this:
nav {
background-color: #fc4747;
height: 70px;
display: flex;
align-items: center; }
How do I vertically centre the navbar items if the navbar is 70px tall? The default height of a navbar is a bit smaller, around 50px.
So I figured I would address a few things here but first as to your question. If you just want to change the height of the navbar instead of adding a specific height to the nav you could just add extra padding to the navbar to give you your desired height and then you wouldn't have to change a bunch of css throughout the rest of the navbar. So doing this should give the navbar a height of 70px.
.navbar{padding:1rem}
Here is a fiddle of everything I address in this post in action Fiddle Demo
In this fiddle demo I have also added some responsive styles for stacking the navbar links at your collapse width.
Next If you are going to set a background color to the nav there is no reason to use the bg-faded class to the nav as this just gives you the background color for the nav so you can remove that class from your nav.
Then I see in your classes for your nav links you have a white-text class. If you want white text for your navbar your can just use the class of navbar-dark and this will give you lighter text for the navbar instead of using navbar-light. Just figured I would point that out.
Next In bootstrap 4 there is no navbar-header class so this is not necessary unless you are planning on custom styling something here. And the navbar-toggler button is different in bootstrap 4 there are no icon-bar spans they just use the html code for this now ☰
Note: Addressing a huge pet peeve of mine you have h5 tags in your navbar. Not sure why this is but I see people doing this a lot. H tags are supposed to be used in order from h1 down to h6 and are supposed to be directly related to the page that you are on and not for the entire site. If you have a good reason for this practice then by all means keep them there but I am not sure why I see people do this all of the time. To me it is a bad practice just figured I would address this.

Bootstrap navigation troubles - Responsive issues

I'm building a website for a client and running into some issues. I have a fixed top and left menus and everything is working quite nicely in the mobile layout. However, when I'm on a desktop resolution and I hide the left menu, the navigation in the top menu seems to change to right justified (then when I shrink the resolution, the links drop down and the menu doubles in size). I made a div id for it but the only thing I'm really using is margin-left to give my search bar room.
Can anyone help me??? The website is: http://104.193.173.104/modx/index.php?id=1
Here is the code for my top menu:
<div id="main-navbar" class="navbar navbar-inverse" role="navigation">
<!-- Left menu toggle button -->
<button type="button" id="main-menu-toggle">
<i class="navbar-icon fa fa-bars icon"></i>
</button>
<div class="navbar-inner">
<div class="navbar-header">
<div class="nav navbar-nav" style="">
<!-- SEARCH BAR -->
[[$searchBar]]
</div>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-navbar-collapse">
<i class="navbar-icon fa fa-bars"></i>
</button>
</div>
<div id="main-navbar-collapse" class="collapse navbar-collapse main-navbar-collapse">
<div id="main-navigation-container">
<!-- MAIN NAVIGATION -->
[[Wayfinder? &startId=`8` &outerTpl=`outerTplTop` &innerTpl=`innerTplTop` &level=`2`]]
<!-- LOGIN -->
<div class="right clearfix">
<ul class="nav navbar-nav pull-right right-navbar-nav">
<li><i class="dropdown-icon fa fa-sign-in"></i> Login</li>
</ul>
</div>
</div>
</div>
</div>
Here's the CSS for the top nav container:
#main-navigation-container {
margin-left: 347px;
width: auto;
max-height: none;
}
I'm working with Bootstrap 3.3.6 and ModX Revo for my CMS.
Thanks in advance for any help! Let me know if you need me to provide any more code snippets.
Add the following CSS:
.navbar-header{
max-width: 200px;
}

Set bottom navbar menu on the bottom of the page without a position:fixed (bootstrap, css3)

I'd like to change my css so that the page has the bottom menu stay there (like fixed) but without the position:fixed.
Why?
Indeed, using Boostrap 3, I am using navbar-fixed-bottom .
BUT position:fixed is not supported at all on Opera Mini which accounts for 10% almost of mobile browsers (see here).
how can I create this without position:fixed ?
3 constraints:
I never want any scroll: it means if the viewport gets smaller(no matter the size of the viewport: big, small, desktop, tablet...), the menu and image will just get smaller and never any horizontal nor vertical scrollbar.
and I want the menu to stay below the image (the quality of the image, distorted or not, is not my point in this question).
i want only html and css: no javascript nor jquery. thanks
Here is an example of what I would like to do:
Here is my current code using fixed position:
<div>
<nav role="navigation" class="navbar navbar-default navbar-fixed-bottom">
<div class="container">
<!-- Title -->
<div class="navbar-bottom pull-left">
BIGGA
</div>
<!-- The non-Collapsing items on navbar-LEFT -->
<div class="collapse navbar-collapse navbar-left">
<!-- pull-right keeps the drop-down in line -->
<ul class="nav navbar-nav pull-right">
<li>
News
</li>
</ul>
</div>
<!-- 'Sticky' (non-collapsing) right-side menu item(s) -->
<div class="navbar-bottom pull-right">
<ul class="nav pull-left">
<!-- This works well for static text, like a username -->
<li class="navbar-text pull-left">User Name</li>
<!-- Add any additional bootstrap header items. This is a drop-down from an icon -->
<li class="dropup pull-right"> <span class="glyphicon glyphicon-user"></span><b class="caret"></b>
<ul class="dropdown-menu">
<li> Profile
</li>
<li> Logout
</li>
</ul>
</li>
</ul>
<!-- Required bootstrap placeholder for the collapsed menu -->
<button type="button" data-toggle="collapse" data-target=".navbar-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>
<!-- Additional navbar items on the LEFT of the PULL-RIGHT stuff above -->
<div class="collapse navbar-collapse navbar-right">
<!-- pull-right keeps the drop-down in line -->
<ul class="nav navbar-nav pull-right">
<li>Locator
</li>
<li>Extras
</li>
</ul>
</div>
</div>
</nav>
</div>
I will give you an idea, about how it could be solved.
Use 2 divs, one after the other. The 1st div will contain your image, or whatever you want to put in the main content area. Its height is 90%, of course you can change or modify that. The second div is your menubar, the height is 10%, modify it as per your needs. Notice the overflow:auto in the .image_content class, it will contain your main contents, regardless of its length and keep the menubar at the bottom.
<style>
.main_wrapper {
height:100%;
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
z-index:9999;
}
.image_content {
height:90%;
background:red;
overflow:auto;
}
.bottom_menu {
height:10%;
background:blue;
}
</style>
<div class="main_wrapper">
<div class="image_content">
Your main content here
</div>
<div class="bottom_menu">
Menu here
</div>
</div>
Of course, remove the red and blue colors from the divs, they are just for the testing.
Added the following image to better explain what is going on in my code -

Bootstrap responsive navbar collapse misalignment

I've created a navigation bar with a simple contact button on the right hand side using twitter bootstrap v3.
However when the screen size is < 768px it drops outside of the navigation bar.
This is the section with the problem.
<div class="pull-right">
<ul class="nav">
<li id="myContactButton" class="nav-text alternate">Contact Us</li>
</ul>
</div>
http://jsfiddle.net/x9NBC/
I've had a look through the #media queries in the css but I can't figure out which is making it drop down like that.
How can I make it stay in line with the navigation?
Add these Sections
I have added pull-left class to some of the element, mentioning below
<div class="navbar-header pull-left">
Pull left for button
<button type="button" class="navbar-toggle pull-left" data-toggle="collapse" data-target=".navbar-collapse">
Add pull-left for anchor tag also
<a href="index.php" class="pull-left">
Here is the Demo http://jsfiddle.net/x9NBC/6/

How do you keep TwitterBootstrap's navbar fixed on top of the screen for applications with very long vertical page layouts?

I downloaded the bootstrap template from http://www.initializr.com/
My question is how do I keep the navbar fixed on top of the screen whenever I scroll down to the footer of my web page? To have a better idea of what I'm trying to achieve I made a screenshot.
example : On a mobile device perspective the NAVBAR is fixed
example : When I scroll down to the footer of the page I want the NAVBAR to stay fixed on top of the screen. As you can see the NAVBAR fails to stay fixed on top of the screen.
CODE:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a>
<a class="brand" href="#"><img src="img/pldttranssmall.png"></a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active">
Home
</li>
<li>
About
</li>
<li>
Product and Services
</li>
<li>
Investor Relations
</li>
<li>
Get Support
</li>
</ul>
<form class="navbar-form pull-right">
<input class="span2" type="text" placeholder="Search">
<button type="submit" class="btn btn-default">
<i class="icon-search icon-black"></i>Go
</button>
</form>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
How do I achieve this?
Just wrap the navigation bar inside a div and add these css classes to it style it as class="navbar navbar-fixed-top"
Example: http://jsfiddle.net/codovations/Uy5tt/show/
P.S: remove show from the end of the url to see the html
Update: Basically this is what they apply to the div to make it fixed on the top.
.navbar-fixed-top {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
top: 0;
}