Twitter Bootstrap 3.0.3 Navbar Aligning Navbar Header - css

I'm having difficulty to centering my navbar brand logo.
currently, my logo will align far to the left.
what I want actually to align it center from the first link. Kindly find below for the sample :
Please find below my code at JSFiddle
http://jsfiddle.net/QSa8v/3/
<div id="navbar">
<nav role="navigation" class="navbar-custom">
<div class="navbar-header">
<button data-toggle="collapse" data-target="#ren-nav-collapse" class="navbar-toggle">
<span class="sr-only">
Toggle navigation
</span>
<span class="icon-bar" />
<span class="icon-bar" />
<span class="icon-bar" />
</button>
<a href="#" class="navbar-brand">
<img src="http://i.imgur.com/CMEnIo7.png" />
</a>
</div>
<div class="collapse navbar-collapse" id="ren-nav-collapse">
<ul class="nav navbar-nav">
<li>
LINK 1
</li>
<li>
LINK 2
</li>
<li>
LINK 3
</li>
<li>
LINK 4
</li>
<li>
LINK 5
</li>
<li>
LINK 6
</li>
</ul>
</div>
</nav>
</div>
Really need your kind answer.

Look at here : http://jsfiddle.net/QSa8v/4/
HTML changes :
<div id="navbar">
<nav role="navigation" class="navbar-custom">
<div class="navbar-header col-xs-3 myheader"> // CHANGE HERE
<button data-toggle="collapse" data-target="#ren-nav-collapse" class="navbar-toggle">
<span class="sr-only">
Toggle navigation
</span>
<span class="icon-bar" />
<span class="icon-bar" />
<span class="icon-bar" />
</button>
<a href="#" class="navbar-brand mybrand"> // CHANGE HERE
<img src="http://i.imgur.com/CMEnIo7.png" />
</a>
</div>
<div class="collapse navbar-collapse" id="ren-nav-collapse">
<ul class="nav navbar-nav mybar"> // CHANGE HERE
<li>
LINK 1
</li>
<li>
LINK 2
</li>
<li>
LINK 3
</li>
<li>
LINK 4
</li>
<li>
LINK 5
</li>
<li>
LINK 6
</li>
</ul>
</div>
</nav>
</div>
CSS added :
.mybar {
margin-left:0px !important;
}
.mybrand{
float:none !important;
}
.myheader{
text-align: center;
padding: 1em;
}

Related

How to create a gap above navigation bar where we place text or buttons in bootstrap 4?

I want to create a gap above navigation bar for echo name like: Welcome Sarah! Kindly check the image what output I am getting:
In above image I want to echo Welcome Sarah above the Login | Sign Up buttons.
I want to show search bar above the Adidad Shoe Store Starting from let-top. And welcome Sarah on the right-end. Then navigation will show.
my code:
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="container">
<div class="row float-right" >
// Search bar
<input type="text" placeholder="Search" name="search">
Hello Sarah!
</div>
</div>
<nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light">
<a class="navbar-brand" href="#">Adidas Shoe Store</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb" aria-expanded="true">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navb" class="navbar-collapse collapse hide">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#" style="color:#007bff;">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Page 2</a>
</li>
</ul>
<ul class="nav navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#"><span class="fas fa-user"></span> Sign Up</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#"><span class="fas fa-sign-in-alt"></span> Login</a>
</li>
</ul>
</div>
</nav>
This is not working as expected because Bootstrap .fixed-top class assigns z-index value of 1030 and position:fixed at top to the nav.
As a result, the .container you added is displayed both behind and not above the nav.
The .container needs position other than static and z-index greater than 1030 to display above the nav. Additionally, the nav needs some padding-top to make visual space for the .container contents in this scenario.
The following structure and added CSS achieves the effect you're looking for:
<div class="container" style="position: relative; z-index: 1031; padding: .5rem 1rem;">
<div class="row">
<div class="col-sm-6">
<input type="text" placeholder="Search" name="search">
</div>
<div class="col-sm-6 text-right">
Hello Sarah!
</div>
</div>
</div>
<nav class="navbar navbar-expand-lg fixed-top navbar-light bg-light" style="padding-top: 2.5rem">
(I've thrown in two .col-sm-6 divs inside your .row to make things easier to arrange on mobile resolutions; also note that .container class is of limited width unlike nav so you should change it to .container-fluid)

Bootstrap + Mobile Menu Overlay

I have a page that uses Bootstrap 3. In this page, I have a navbar that's defined like the following:
<nav class="navbar" style="background-color:orange;">
<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" style="color:#000 !important;">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar" style="color:#000;"></span>
<span class="icon-bar" style="color:#000;"></span>
<span class="icon-bar" style="color:#000;"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="/home" class="dropdown-toggle navbar-dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Home <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>help</li>
<li>contact</li>
</ul>
</li>
</ul>
<div class="navbar-right">
<div class="visible-xs">
<div class="row">
<div class="col-xs-6">
2016
<ul class="dropdown-menu dropdown-menu-right">
<li>Q1</li>
<li>Q2</li>
<li>Q3</li>
<li>Q4</li>
</ul>
</div>
<div class="col-xs-6">
2017
<ul class="dropdown-menu dropdown-menu-right">
<li>Q1</li>
<li>Q2</li>
<li>Q3</li>
<li>Q4</li>
</ul>
</div>
</div>
</div>
<div class="hidden-xs">
<ul class="nav navbar-nav">
<li>
2016
<ul class="dropdown-menu dropdown-menu-right">
<li>Q1</li>
<li>Q2</li>
<li>Q3</li>
<li>Q4</li>
</ul>
</li>
<li>
2017
<ul class="dropdown-menu dropdown-menu-right">
<li>Q1</li>
<li>Q2</li>
<li>Q3</li>
<li>Q4</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
The navbar looks and works like I want on bigger screens. But on mobile, it doesn't work correctly. As you can see in this Bootply, the nav menu pushes the main content (the Lorem Ipsum) down. However, I want the nav menu to appear on top of the content, so that the mobile nav appears on top of the Lorem Ipsum stuff. What am I doing wrong?
Do you want like this:
http://www.bootply.com/9OB6nhtg4i#
#media (max-width:768px) {
.navbar {
position: absolute;
}
}
Add this css and try.
U need to use navbar-fixed-top class and set top padding for main block:
main {
padding-top: 60px;
}
http://www.bootply.com/aROSWOLDZY

Display a user's picture or avatar in the header using twitter bootstrap

I am trying to insert the user's avatar next to the username in the bootstrap 3 header. I'm having a very hard time achieving this, and I don't want to hack into the provider's css. Any one has already done this ? Thanks for your help
<div class="navbar navbar-inverse 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>
Foo's Bar
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Awesome link</li>
<li>More Awesome link</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
Something <span id ="toto" class="badge" style="#danger">0</span>
</li>
<li>
<li><img src="http://placehold.it/30x30"><span class="header-username">Chuck Norris</span></li>
<li>Log off</li>
</ul>
</div>
</div>
</div>
Edit : the Bootply's link, because that's what friends do ! http://www.bootply.com/X4FhzJiP3T
The avatar appears next to the username. If it's a styling or placement issue you're experiencing, just add a custom class to the avatar image and style accordingly
.avatar {
/* put custom avatar css here */
}
I also added the .img-responsive class to the avatar...
<li>
<a href="#">
<img src="http://placehold.it/30x30" class="avatar img-responsive">
<span class="header-username">Chuck Norris</span>
</a>
</li>

Navbar opens and collapse suddenly

<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0" />
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel = "stylesheet" href="css/bootstrap-responsive.min.css">
</head>
<body>
<div class = "container">
<div class="navbar" >
<div class ="navbar-header">
<!-- Place your logo here -->
<div class="navbar-brand" >
<img src="images/logo.png" alt="logo text">
</div>
</div>
<button type="button" class="navbar-toggle navbar-right " data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"><hr><hr><hr></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class=" collapse navbar-collapse nav-collapse ">
<ul class="nav navbar-nav navbar-right">
<!-- Add require site page navigation -->
<li> <i class="icon-globe"></i>HOME</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" style="color:#000000"><i class="icon-user"></i>About Us<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>The Company</li>
<li>Vision</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" style="color:#000000"><i class="icon-user" style="color:#000000"></i>Team<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>Meet Our Team</li>
<li>Our Sister concerns</li>
</ul>
</li>
<li><i class="icon-pencil"></i>Projects</li>
Refer
Contact Us
Web
Locate
</ul>
</div>
</div>
</div>
check the problem at www.alaknandainfra.com/refer.php the nav bar collapses suddenly in mobile view . i spent many hours but can't find the mistake . and i want to align the toggle menu on the right side . when user click on toggle button the menu should come on the right side
If you remove the height:0 at bootstrap-responsive.min.css:1240, that issue seems to be fixed.
.nav-collapse,.nav-collapse.collapse{
/* height:0; */
overflow:hidden
}

How can I control the size at which Foundation Nav bar goes to mobile display?

I have a Foundation 5 based site with a nav bar at the top.
Because my menu choices are larger text they overlap the left "Name" section when the screen is made narrower.
Is there a way to control when the nav menu slips into mobile style?
<nav class="top-bar" data-topbar role="navigation">
<ul class="title-area">
<li class="name">
<div class="logo">
<a href="#">
<img src="mylogo.png"/>
</a>
</div>
</li>
<li class="toggle-topbar menu-icon">
<a href="#">
<span></span>
</a>
</li>
</ul>
<section class="top-bar-section hide-for-medium-down ">
<!-- Right Nav Section -->
<ul class="right">
<li class="active">
<a href="/home/index" class="menuMix">
#*<span class="menuMinor">Home Page</span>*#
<span class="menuMain allCaps">Home</span>
</a>
</li>
<li class="">
<a href="/home/about" class="menuMix">
#*<span class="menuMinor">Who We Are</span>*#
<span class="menuMain allCaps">About</span>
</a>
</li>
<li class="">
<a href="/home/contact" class="menuMix">
#*<span class="menuMinor">Get In Touch</span>*#
<span class="menuMain allCaps">Contact</span>
</a>
</li>
</ul>
</section>
</nav>
If you use SCSS you can try to decrease
$topbar-link-weight: $font-weight-normal;
$topbar-link-font-size: rem-calc(13);

Resources