How can I darken the background when a linked is clicked? - php

I am currently working on the navbar of my website.
There are five elements on my navbar and I'd like to make an element darker when it is clicked.
These is what I've tried so far:
jQuery to change the active element:
<script type="text/javascript">
$(function(){
$('nav navbar-nav a').filter(function(){return this.href==location.href}).parent().addClass('active').siblings().removeClass('active')
$('nav navbar-nav a').click(function(){
$(this).parent().addClass('active').siblings().removeClass('active')
})
})
</script>
The five elements on the navbar:
<nav class = "navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Intern Web</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">About</li>
<li>News</li>
<li>Intern</li>
<li>Form</li>
</ul>
This is a screenshot of the website:
But it seems to not be working, only About is selected every single time.
Any ideas? Thanks a lot.

<script type="text/javascript">
$(function(){
$(".navbar-nav li a").on('click',function(){
$(nav-bar-nav li).toggleClass("active");
});
});
<ul class="nav navbar-nav">
<li class="">About</li> /*Just remove active class and add with js*/
<li>News</li>
<li>Intern</li>
<li>Form</li>
</ul>
.active{
background:black;
}
.active a{
color:#ffffff;
}

Use code as below:
DO NOT forget . before className in JQuery:
$('.nav .navbar-nav a') instaed $('nav navbar-nav a')
$('.navbar-nav li a').click(function(){
$(".navbar-nav li").removeClass("active");
$(this).parent().addClass("active");
});
.active{
background:black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class = "navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Intern Web</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active">About</li>
<li>News</li>
<li>Intern</li>
<li>Form</li>
</ul>

I Guess You are probably providing the wrong selector to jQuery
$('div.nav li a').click(function(){
$(this).parent().addClass('active').siblings().removeClass('active')
})
})
The Selectors
$("nav li a") or $(".navbar-nav li a")
Should work fine

Simply remove the active class on the li's on the click and then assign it to the li that was clicked:
$('.navbar-nav li').click(function(){
$('.navbar-nav li').removeClass('active');
$(this).addClass('active')
})
.navbar-nav li {
list-style: none;
display: inline;
padding: 5px 10px;
background: #d4d4d4;
}
.navbar-nav li a {
color: #222;
text-decoration: none;
}
.navbar-nav li.active {
background: black;
}
.navbar-nav li.active a {
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="nav navbar-nav">
<li class="active">About</li>
<li>News</li>
<li>Intern</li>
<li>Form</li>
</ul>

Related

Bootstrap navbar logo in the center and items to the left und right

I try to make a proper navbar with bootstrap.
I tried to make a logo in the center and the rest on the left and on the right.
The current solution is unclean and I ask you for an adivce, how to fix it.
Problem: It's not the same length to the left/right object from the logo AND the logo is not perfect centered.
[Navbar][1]
Current html:
<nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top">
<div class="container">
<button class="navbar-toggler" data-toggle="collapse" data-target="#navbarMenu">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarMenu">
<ul class="navbar-nav mr-auto">
<li class="nav-item">Status</li>
<li class="nav-item">Download</li>
<li class="nav-item">Teamspeak</li>
<li class="nav-item">Teamspeak</li>
</ul>
<a class="navbar-brand" href="#">
<img src="/img/helmet.png" height="100" with="50" alt="">
</a>
<ul class="navbar-nav mr-auto">
<li class="nav-item">Teamspeak Bot</li>
<li class="nav-item">Travel</li>
<li class="nav-item">Plex</li>
<li class="nav-item">Contact</li>
</ul>
</div>
</div>
</nav>
CSS
.collapse.navbar-collapse ul{
margin: auto;
}
.navbar-brand {
position: absolute;
top: 0;
left: 50%;
text-align: center;
margin: auto;
font-size: 36px;
}
.bg-dark {
background:transparent !important;
background-image: url("/img/navbar.png") !important;
min-height: 70px;
}
You can use pull-right class to align the items to the right, but it need few more modifications to work correctly.I have created a clean solution with the links that you provided.Enjoy!
body { background-color: blueviolet !important; }
.navbar {
position: relative;
top:10px;
}
.brand {
position: absolute;
left: 50%;
margin-left: -50px !important;
display: block;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<!--If you want to add background image add it to the class below-->
<div class="container-fluid"><!--add this line-->
<div class="row"><!--add this line-->
<div class="col-md-12"><!--add this line-->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="brand" style="margin: 0; float: none;" href="#">
<!--add logo source-->
<img src="icon.png" alt="logo" title="logo" height="100" with="50" />
</a>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">Status</li>
<li class="nav-item">Download</li>
<li class="nav-item">Teamspeak</li>
<li class="nav-item">Teamspeak</li>
</ul>
<ul class="navbar-nav pull-right">
<li class="nav-item">Teamspeak Bot</li>
<li class="nav-item">Travel</li>
<li class="nav-item">Plex</li>
<li class="nav-item">Contact</li>
</ul>
</div>
</div>
</nav>
</div><!--add this line-->
</div><!--add this line-->
<!--New Row for the main content-->
<div class="row">
<div class="col-md-12">
<!--Main content-->
</div>
</div>
</div><!--add this line-->
Change class on second tag to ml-auto since the right side pane must be aligned with margin on the left. This should fix it.
<nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top">
<div class="container">
<button class="navbar-toggler" data-toggle="collapse" data-target="#navbarMenu">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarMenu">
<ul class="navbar-nav mr-auto">
<li class="nav-item">Status</li>
<li class="nav-item">Download</li>
<li class="nav-item">Teamspeak</li>
<li class="nav-item">Teamspeak</li>
</ul>
<a class="navbar-brand" href="#">
<img src="/img/helmet.png" height="100" with="50" alt="">
</a>
<ul class="navbar-nav ml-auto"> <!-- change here -->
<li class="nav-item">Teamspeak Bot</li>
<li class="nav-item">Travel</li>
<li class="nav-item">Plex</li>
<li class="nav-item">Contact</li>
</ul>
</div>
</div>
</nav>

Add Active Class to sidebar Item Based on URL

I am using laravel and when the page is refresh the active item on sidebar is not selected, this : li class="{{ (request()->is('admin/cities*')) ? 'active' : '' }}"> (is a easy solution), but not looks great. How i can make this using jquery or other?
$(document).ready(function() {
$('ul li a').click(function() {
$('li a').removeClass("active");
$(this).addClass("active");
});
});
<style>.sidebar-link.active,
.sidebar-link:focus {
background: #e2e8ed;
color: grey !important;
text-decoration: none;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="sidebar" class="sidebar py-3">
<ul class="sidebar-menu list-unstyled">
<li class="sidebar-list-item"><a href="/test" class="sidebar-link text-
muted active"><i class="la la-dashboard mr-3 text-gray "></i>
<span>Dashboard</span></a>
</li>
<li class="sidebar-list-item"><a href="/test2" class="sidebar-link text-
muted"><i class="la la-dashboard mr-3 text-gray "></i>
<span>Test</span></a>
</li>
<ul>
</div>

dropdown bootstrap not working in mobile

I'm having an issue where a dropdown menu in my website works on a desktop, but failed in mobile view.
The following is an example of a website I created: http://www.pakarraya.com/dropdown/
according to some examples of bootstrap dropdown menus in various references, here's the script I wrote:
<div class="navigation collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li class="current">Home</li>
<li>About</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Menu Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
<li>Dropdown 3</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
I beg for solutions from advanced colleagues, thank you very much
This will perfectly solves your problem please check i have uploaded screen shot also
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.topnav {
overflow: hidden;
background-color: #333;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.active {
background-color: #4CAF50;
color: white;
}
.topnav .icon {
display: none;
}
#media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
</style>
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
</head>
<body>
<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="#">Brand</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 navbar-right">
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li class="current">Home</li>
<li>About</li>
<li class="dropdown-menu">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Menu Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Dropdown 1</li>
<li>Dropdown 2</li>
<li>Dropdown 3</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</body>
</html>
Output
[![screenshot][1]][1]

PHP script feedback in webpage

I am trying a build a web portal which runs a php script script that calls a batch file in windows, which in turn executes a powershell script that run powercli to fetch required info from vmware vcenter. All the result is sent to a file named f1.txt and f1.html sources this file and displays the output.All my codes are below.
The below solution works but, I have a requirement to display some output instead of a blank page when f1.php script is running and waiting for output from the underlying powershell script f1.bat -> f1.ps1.
Some progress report or direct feedback from the php script would do while the webpage is waiting the php script to finish.
For eg: Loading... with blinking dots or output from the script itself.
I have tried the flush() method and ob_flush() method in f1.php but it just gives me a blank screen with the output and once the php script completes running the nav bar gets loaded below that output.The page is all mangled.
How can I get the desired result with minimal code manipulation. If ajax or javascript is required for the task, then I'm open to that as well.
I have the below in index.php
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.dropdown-submenu {
position: relative;
}
.dropdown-submenu .dropdown-menu {
top: 0;
left: 100%;
margin-top: -1px;
}
#media (min-width: 979px) {
ul.nav li.dropdown:hover > ul.dropdown-menu {
display: block;
}
}
ul.nav li.dropdown-submenu:hover > ul.dropdown-menu {
display: block;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse ">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">VMware VC Reports</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="dropdown"><a class="dropdown" data-toggle="dropdown" href="#">Vcenters<span class=caret></span></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">San Jose Vcenter<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="http://mickey.example.com/view/f1.php">ESX Info</a></li>
<li><a tabindex="-1" href="http://mickey.example.com/view/f2.php">Firmware Info</a></li>
</li>
</ul>
</li>
</ul>
</ul>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('.dropdown-submenu a.test').on("click", function(e){
$(this).next('ul').toggle();
e.stopPropagation();
e.preventDefault();
});
});
</script>
</body>
</html>
I have the below in f1.php file.
<?php
system("f1.bat");
header("Location:http://mickey.example.com/view/f1.html");
exit;
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.dropdown-submenu {
position: relative;
}
.dropdown-submenu .dropdown-menu {
top: 0;
left: 100%;
margin-top: -1px;
}
#media (min-width: 979px) {
ul.nav li.dropdown:hover > ul.dropdown-menu {
display: block;
}
}
ul.nav li.dropdown-submenu:hover > ul.dropdown-menu {
display: block;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse ">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">VMware VC Reports</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="dropdown"><a class="dropdown" data-toggle="dropdown" href="#">Vcenters<span class=caret></span></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">San Jose Vcenter<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="http://mickey.example.com/view/f1.php">ESX Info</a></li>
<li><a tabindex="-1" href="http://mickey.example.com/view/f2.php">Firmware Info</a></li>
</li>
</ul>
</li>
</ul>
</ul>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('.dropdown-submenu a.test').on("click", function(e){
$(this).next('ul').toggle();
e.stopPropagation();
e.preventDefault();
});
});
</script>
</body>
</html>
I have the below in f1.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.dropdown-submenu {
position: relative;
}
.dropdown-submenu .dropdown-menu {
top: 0;
left: 100%;
margin-top: -1px;
}
#media (min-width: 979px) {
ul.nav li.dropdown:hover > ul.dropdown-menu {
display: block;
}
}
ul.nav li.dropdown-submenu:hover > ul.dropdown-menu {
display: block;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse ">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">VMware VC Reports</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="dropdown"><a class="dropdown" data-toggle="dropdown" href="#">Vcenters<span class=caret></span></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">San Jose Vcenter<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="http://mickey.example.com/view/f1.php">ESX Info</a></li>
<li><a tabindex="-1" href="http://mickey.example.com/view/f2.php">Firmware Info</a></li>
</li>
</ul>
</li>
</ul>
</ul>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('.dropdown-submenu a.test').on("click", function(e){
$(this).next('ul').toggle();
e.stopPropagation();
e.preventDefault();
});
});
</script>
<script type="text/javascript">
<!--
var iframe = document.createElement("iframe");
iframe.src = "f1.txt";
iframe.width = "20000";
iframe.height = "20000";
iframe.frameBorder = "0";
iframe.scrolling = "no";
document.body.appendChild(iframe);
//-->
</script>
</body>
</html>

Bootstrap Navbar collapses when it's not supposed to

I've got a header page which contains a navbar, logo and another navbar.
On a desktop the first navbar contains the information to the right hand side which is perfect as seen below:
However when I change to a small screen it comes up like below:
Is there a way to change this so that on a small screen it it won't collapse?
If any css is needed is it also possible to change the ID so it will not interfere with my other NavBar and its CSS?
At the moment my code:
<div class="container-fluid">
<ul class="nav navbar-nav navbar-right">
<li><span class="glyphicon glyphicon-user"> </span> Sign Up</li>
<li><span class = "glyphicon glyphicon-log-in"></span> Login</li>
<li><span class="glyphicon glyphicon-shopping-cart"></span> <?php echo 'Checkout' ?> </li>
</ul>
</div>
Thank you for any help!
Edit:
This is my other navbar which sits below my logo which works perfectly:
I hope this helps some more.
<div class="container">
<nav class="navbar navbar-default" role="navigation">
<!-- 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=".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>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Home</li>
<li>Collections</li>
<li>Jewellry</li>
<li>Offers</li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
</div>
CSS for this navbar:
.navbar .navbar-nav {
display: inline-block;
float: none;
color: #000000;
}
.navbar .navbar-collapse {
text-align: center;
}
.navbar-default {
background-color: #44B5DB;
border-color: #000000;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
background-color: #FFFFFF;
color: #000000;
}
.navbar-default .navbar-nav > li > a {
color: #000000;
}
I thought it might be easier showing a picture.
So basically my Navbar #1 needs to show:
Sign up | Login | Checkout
Even on small devices rather than one on top of each other.
As per the picture my current setup is: Navbar #1, Logo, Navbar #2
I hope this makes sense!
You can add some customization to the upper-navigation div to it doesn't collapse by using the navbar-default class as a base. And the upper and lower navbars lineup (they don't have to though).
I also adjusted your CSS so the links line-height works when you hover over them; the gap is removed now from the bottom.
.navbar-default.nav-top {
background: #fff;
}
.navbar-default.nav-top ul {
display: inline-block;
float: right;
}
.navbar-default .navbar-top li {
float: left;
font-size: 12px;
}
.navbar.navbar-custom {
background: #44B5DB;
border-color: #000000;
}
.navbar.navbar-custom .navbar-nav > li > a {
color: #000000;
}
.navbar.navbar-custom .navbar-nav > li > a:hover,
.navbar.navbar-custom .navbar-nav > li > a:focus {
background: #FFFFFF;
color: #000000;
width: 100%;
}
.navbar.navbar-custom .navbar-nav {
text-align: center;
}
#media (min-width: 768px) {
.navbar.navbar-custom .navbar-nav > li {
float: none;
display: inline-block;
}
.navbar.navbar-custom .navbar-nav {
width: 100%;
text-align: center;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<nav class="navbar-default nav-top">
<div class="container">
<ul class="nav navbar-top">
<li><span class="glyphicon glyphicon-user"> </span> Sign Up
</li>
<li><span class = "glyphicon glyphicon-log-in"></span> Login
</li>
<li><span class="glyphicon glyphicon-shopping-cart"></span> <?php echo 'Checkout' ?>
</li>
</ul>
</div>
</nav>
<div class="container">
<nav class="navbar navbar-default navbar-custom">
<!-- 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-navbar" 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>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-navbar">
<ul class="nav navbar-nav">
<li>Home
</li>
<li>Collections
</li>
<li>Jewellry
</li>
<li>Offers
</li>
</ul>
</div>
</nav>
</div>
Just make sure the list elements in your top navbar will be floated left on small screens. You also might want to float the parent element to the right.
I have added some extra classes so you do not overwrite the default style, because you do not want to affect other navbars as i suggest.
I am sure you will get the idea.
#import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css");
/* Keep list elements floated so they do not collapse */
.navbar-nav>li.top-nav {
float: left;
}
/* keep the ul floated to the right */
.top-nav-right {
float: right!important;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
color: #000000;
}
.navbar .navbar-collapse {
text-align: center;
}
.navbar-default {
background-color: #44B5DB;
border-color: #000000;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
background-color: #FFFFFF;
color: #000000;
}
.navbar-default .navbar-nav > li > a {
color: #000000;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<div class="container-fluid">
<ul class="nav navbar-nav navbar-right top-nav-right">
<li class="top-nav"><span class="glyphicon glyphicon-user"> </span> Sign Up</li>
<li class="top-nav"><span class = "glyphicon glyphicon-log-in"></span> Login</li>
<li class="top-nav"><span class="glyphicon glyphicon-shopping-cart"></span> <?php echo 'Checkout' ?> </li>
</ul>
</div>
<div class="container">
<nav class="navbar navbar-default" role="navigation">
<!-- 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=".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>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Home</li>
<li>Collections</li>
<li>Jewellry</li>
<li>Offers</li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
</div>

Categories