I am trying to show Result in search box using ajax and php, everything is working fine but the problem is occurring in displaying the result, it simply breaks the navbar.
this i the nav-bar code
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<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>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<div class="col-sm-6 col-md-6">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" onkeyup="showresult(this.value)" name="q" autocomplete='off'>
<div id="livesearch"></div>
<div class="input-group-btn"><button class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
</div>
</form>
</div>
<ul class="nav navbar-nav navbar-right">
/*code Reducted */
<li> <span class="glyphicon glyphicon-shopping-cart"></span> Shopping Cart</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
can anyone help me how to display the result as of google
may be i am missing some thing, i am still learning.
So ok i try hard with google and get a answer
#livesearch
{
position: absolute;
width: auto;
background: white;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
max-height: 200px;
overflow-y: auto;
border: 1px solid gray;
/*This is relative to the navbar now*/
left: 0;
right: 0;
top: 40px;
}
this helps me to solve the problem
Related
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>
I have a navigation toggle it appears when screen is small after i included 1 php file which which is bootstrap modal, after including that my navigation toggle is not closing after opening.Im unable to close the navigation menu.
I have include both the files index as well as request which is data modal file
<?php require 'request.php';?>
<header class="navigation navbar navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<!-- responsive nav button -->
<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>
<!-- /responsive nav button -->
<!-- logo -->
<a class="navbar-brand logo" href="index.html">
<img class="logo-white" src="images/logo1.png" alt="logo" style="width:40px;float:left;"/>
<p class="logo-white" style="float:right;font-size: 30px;color: white;font-family: initial;margin-top:5px;margin-left:8px;">Expert Web Solutions</p>
<img class="logo-default" src="images/logo2.png" alt="logo" style="width:40px;float:left;"/>
<p class="logo-default" style="float:right;font-size: 30px;color: #000;font-family: initial;margin-top:5px;margin-left:8px;">Expert Web Solutions</p>
</a>
<!-- /logo -->
</div>
<!-- main nav -->
<nav class="collapse navbar-collapse navbar-right">
<ul id="nav" class="nav navbar-nav menu">
<li>
<a href="index.html" >Home </span></a>
</li>
<li class="dropdown">
Services <span class="caret"></span>
<ul class="dropdown-menu">
<li>Mobile App Development</li>
<li>Web Development</li>
<li>Software Development</li>
<li>Software Consultancy</li>
<li>Software Testing and<br> Quality Assurance</li>
</ul>
</li>
<li>Technologies</li>
<li>About Us</li>
<li>Careers</li>
<li><button type="button" data-toggle="modal" data-target="#myModal">Request A Quote</button></li>
<li>Contact Us</li>
</li>
</ul>
</nav>
<!-- /main nav -->
</div>
</header>
<this is request.php>
<!DOCTYPE html>
<html lang="en">
<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>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="form.css" >
<script src="form.js"></script>
</head>
<body>
<div class="container">
<!-- Trigger the modal with a button -->
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Request A Quote</h4>
</div>
<div class="panel-body">
<form id="reused_form">
<div class="form-group">
<input type="text" name="name" required class="form-control" placeholder="Enter Name">
</div>
<div class="form-group">
<input type="email" name="email" required class="form-control" placeholder="Enter Email">
</div>
<div class="form-group">
<input name="phone" class="form-control" placeholder="Enter Phone Number">
</div>
<div class="form-group">
<textarea rows="3" name="message" class="form-control" placeholder="Write Your Requirements"></textarea>
</div>
<div class="form-group">
<button class="btn btn-raised btn-lg btn-warning" type="submit" style="
border: none;
padding: 15px 0;
width: 100%;
margin: 0;
background: #2b315d;
color: #fff;
border-radius: 0;
">Send</button>
</div>
</form>
<div id="error_message" style="width:100%; height:100%; display:none; ">
<h4>
Error
</h4>
Sorry there was an error sending your form.
</div>
<div id="success_message" style="width:100%; height:100%; display:none; ">
<h2 style="color:#000; font-size:22px;text-align:center;">Thank You! <br>Your Message was Sent Successfully.<br>One of our representatives will contact you shortly.</h2>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
I think require.php breaks the html including head section again and opening and closing html and body tags.
Maybe this will work ?
<!DOCTYPE html>
<html lang="en">
<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>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="form.css" >
<script src="form.js"></script>
</head>
<body>
<header class="navigation navbar navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<!-- responsive nav button -->
<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>
<!-- /responsive nav button -->
<!-- logo -->
<a class="navbar-brand logo" href="index.html">
<img class="logo-white" src="images/logo1.png" alt="logo" style="width:40px;float:left;"/>
<p class="logo-white" style="float:right;font-size: 30px;color: white;font-family: initial;margin-top:5px;margin-left:8px;">Expert Web Solutions</p>
<img class="logo-default" src="images/logo2.png" alt="logo" style="width:40px;float:left;"/>
<p class="logo-default" style="float:right;font-size: 30px;color: #000;font-family: initial;margin-top:5px;margin-left:8px;">Expert Web Solutions</p>
</a>
<!-- /logo -->
</div>
<!-- main nav -->
<nav class="collapse navbar-collapse navbar-right">
<ul id="nav" class="nav navbar-nav menu">
<li>
<a href="index.html" >Home </span></a>
</li>
<li class="dropdown">
Services <span class="caret"></span>
<ul class="dropdown-menu">
<li>Mobile App Development</li>
<li>Web Development</li>
<li>Software Development</li>
<li>Software Consultancy</li>
<li>Software Testing and<br> Quality Assurance</li>
</ul>
</li>
<li>Technologies</li>
<li>About Us</li>
<li>Careers</li>
<li><button type="button" data-toggle="modal" data-target="#myModal">Request A Quote</button></li>
<li>Contact Us</li>
</li>
</ul>
</nav>
<!-- /main nav -->
</div>
</header>
<?php require 'request.php';?>
</body>
</html>
below request PHP
<!-- Trigger the modal with a button -->
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Request A Quote</h4>
</div>
<div class="panel-body">
<form id="reused_form">
<div class="form-group">
<input type="text" name="name" required class="form-control" placeholder="Enter Name">
</div>
<div class="form-group">
<input type="email" name="email" required class="form-control" placeholder="Enter Email">
</div>
<div class="form-group">
<input name="phone" class="form-control" placeholder="Enter Phone Number">
</div>
<div class="form-group">
<textarea rows="3" name="message" class="form-control" placeholder="Write Your Requirements"></textarea>
</div>
<div class="form-group">
<button class="btn btn-raised btn-lg btn-warning" type="submit" style="
border: none;
padding: 15px 0;
width: 100%;
margin: 0;
background: #2b315d;
color: #fff;
border-radius: 0;
">Send</button>
</div>
</form>
<div id="error_message" style="width:100%; height:100%; display:none; ">
<h4>
Error
</h4>
Sorry there was an error sending your form.
</div>
<div id="success_message" style="width:100%; height:100%; display:none; ">
<h2 style="color:#000; font-size:22px;text-align:center;">Thank You! <br>Your Message was Sent Successfully.<br>One of our representatives will contact you shortly.</h2>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
I currently have the following code.
The circle buttons are basically navigation buttons. The second div is where I have a collapsable list.
I would like to have the list on the right-hand side of the navigation.
I have attempted to wrap the divs and also use float as left, for some reason it is still not working. If someone could assist?
html, body {
background-color: #fff;
color: rgba(255, 43, 62, 0.84);
font-family: 'Raleway', sans-serif;
font-weight: 100;
height: 100vh;
margin: 10px;
}
.links > a {
color: #ffffff;
padding-top: 0;
padding-right: 50px;
padding-left: 50px;
padding-bottom: 100px;
font-size: 14px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.round-button {
width:8%;
}
.round-button-circle {
width: 100%;
height:0;
padding-bottom: 100%;
margin: 10%;
border-radius: 110%;
border:3px solid #56660d;
overflow:hidden;
background: #abc729;
box-shadow: 0 0 3px gray;
}
.round-button-circle:hover {
background: #56660d;
}
.round-button a {
display:inline-block;
float:left;
width:100%;
padding-top:45%;
padding-bottom:50%;
line-height:1em;
text-align:center;
color: #ffffff;
font-family:Verdana;
font-size:0.70em;
font-weight:bold;
text-decoration:none;
position: relative;
}
<div class="circle-flex-center cirlce-position-ref circle-full-height">
<div class="round-button">
<div class="round-button-circle">
Personal & Placement Details
</div>
</div>
<div class="round-button">
<div class="round-button-circle">
Tutor Details
</div>
</div>
<div class="round-button">
<div class="round-button-circle">
Assignments & Examples
</div>
</div>
<div class="round-button">
<div class="round-button-circle">
Mark Scheme
</div>
</div>
<div class="round-button">
<div class="round-button-circle">
Submission
</div>
</div>
</div>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapseone" data-toggle="collapse" data-parent="#accordion">
Monthly Reflection
</a>
</h4>
</div>
<div id="collapseone" class="panel-collapse collapse ">
<div class="panel-body">
sjfhdkjs
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapsetwo" data-toggle="collapse" data-parent="#accordion">
Reflection Example
</a>
</h4>
</div>
<div id="collapsetwo" class="panel-collapse collapse">
<div class="panel-body">
adfjkldsf
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapsethree" data-toggle="collapse" data-parent="#accordion">
Tutor Visits
</a>
</h4>
</div>
<div id="collapsethree" class="panel-collapse collapse">
<div class="panel-body">
dilfsklsdgs
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapsefour" data-toggle="collapse" data-parent="#accordion">
Reports
</a>
</h4>
</div>
<div id="collapsefour" class="panel-collapse collapse">
<div class="panel-body">
sfjksdf
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapsefive" data-toggle="collapse" data-parent="#accordion">
Report Example
</a>
</h4>
</div>
<div id="collapsefive" class="panel-collapse collapse">
<div class="panel-body">
difks;ldsf
</div>
</div>
</div>
</div>
A little bit restructured your CSS. I hope that helps.
html, body {
background-color: #fff;
color: rgba(255, 43, 62, 0.84);
font-family: 'Raleway', sans-serif;
font-weight: 100;
height: 100vh;
margin: 10px;
}
.circle-flex-center{
width: 80px;
}
.round-button{
text-align: center;
width: 65px;
height: 65px;
padding: 15px;
margin: 5px;
border:3px solid #56660d;
background-color: #abc729;
border-radius: 110%;
box-shadow: 0 0 3px gray;
float: left;
}
.round-button a{
padding: 5px;
line-height:1em;
color: #ffffff;
font-family:Verdana;
font-size:0.60em;
font-weight:bold;
text-decoration:none;
}
.round-button:hover{
background: #56660d;
}
.panel-group{
float: right;
margin-top: -65%;
}
.links > a {
color: #ffffff;
padding-top: 0;
padding-right: 50px;
padding-left: 50px;
padding-bottom: 100px;
font-size: 14px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
<div class="circle-flex-center cirlce-position-ref circle-full-height">
<div class="round-button">
<div class="round-button-circle">
<a href="student-personaldetails" >Personal & Placement Details</a>
</div>
</div>
<div class="round-button">
<div class="round-button-circle">
<a href="student-tutordetails" >Tutor Details</a>
</div>
</div>
<div class="round-button">
<div class="round-button-circle">
<a href="student-placementassignment" >Assignments & Examples</a>
</div>
</div>
<div class="round-button">
<div class="round-button-circle">
<a href="student-markscheme" >Mark Scheme</a>
</div>
</div>
<div class="round-button">
<div class="round-button-circle">
<a href="student-submission" >Submission</a>
</div>
</div>
</div>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapseone" data-toggle="collapse" data-parent="#accordion">
Monthly Reflection
</a>
</h4>
</div>
<div id="collapseone" class="panel-collapse collapse ">
<div class="panel-body">
sjfhdkjs
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapsetwo" data-toggle="collapse" data-parent="#accordion">
Reflection Example
</a>
</h4>
</div>
<div id="collapsetwo" class="panel-collapse collapse">
<div class="panel-body">
adfjkldsf
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapsethree" data-toggle="collapse" data-parent="#accordion">
Tutor Visits
</a>
</h4>
</div>
<div id="collapsethree" class="panel-collapse collapse">
<div class="panel-body">
dilfsklsdgs
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapsefour" data-toggle="collapse" data-parent="#accordion">
Reports
</a>
</h4>
</div>
<div id="collapsefour" class="panel-collapse collapse">
<div class="panel-body">
sfjksdf
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a href="#collapsefive" data-toggle="collapse" data-parent="#accordion">
Report Example
</a>
</h4>
</div>
<div id="collapsefive" class="panel-collapse collapse">
<div class="panel-body">
difks;ldsf
</div>
</div>
</div>
</div>
I am pretty new to Bootstrap and php.
I want my navigation to have a centered brand with logo and the links to different pages left and right next to the logo. Then I want to have social media icons on the top right.
In the mobile view I want a different order of menu items. the brand with logo on the top and the social media at the bottom.
Does this make any sense? Here is my code so far. I have no idea how I can use the navwalker on this custom menu.
<a class = "navbar-brand visible-xs" href = "<?php echo esc_url(home_url()); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/logo.png" alt="logo">" width="50">
</a><!-- /navbar-brand visible-xs -->
<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> <!-- /navbar-toggle -->
</div> <!-- /navbar-header -->
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right hidden-xs social ">
<li><i class="fa fa-lg fa-facebook"></i></li>
<li><i class="fa fa-lg fa-instagram"></i></li>
<li><i class="fa fa-lg fa-500px"></i></li>
</ul><!-- /hidden-xs social -->
<ul class="nav navbar-nav navbar-center">
<li>HOME</li>
<li>PORTFOLIO</li>
<li class="dropdown hidden-xs"><img id="logo-navbar-middle" src="C:\Users\Carolin_2\Desktop\nicole\logonew.png" width="50"</img></li>
<li>LEISTUNGEN</li>
<li>KONTAKT</li>
</ul><!-- /navbar-nav -->
<ul class="nav navbar-nav navbar-center visible-xs social nav-pills">
<li><i class="fa fa-lg fa-facebook"></i></li>
<li><i class="fa fa-lg fa-instagram"></i></li>
<li><i class="fa fa-lg fa-500px"></i></li>
</ul><!-- /visible-xs social -->
</div> <!-- /navbar-collapse-->
</div><!-- /container fluid-->
CSS Code
/* === NAVBAR ===*/
.navbar{
background-color: black;
margin-bottom: 0;
border: 0;
}
.navbar-inverse .navbar-nav>li>a{
text-align: center;
color: white;
display: inline-block;
float:none;
vertical-align: top;
}
#media (min-width: 768px){
.navbar-nav{
float:none;
margin: 0 auto;
display: table;
table-layout: fixed;
}
}
.navbar .navbar-collapse {
text-align: center;
}
.navbar-inverse .navbar-toggle -.icon-bar{
color: white;
}
Can anybody help me or give me some advice?
Best,
Carolina
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>