i have a problem with my navbar notification button,
the button resize the navbar.
example
here is the code
.badge-notify{
background:red;
position:relative;
top: -20px;
left: -35px;
}
<ul class="nav navbar-nav navbar-right">
<li><a href="#">
<button class="btn btn-lg btn-link">
<span class="glyphicon glyphicon-envelope"></span>
</button>
<span class="badge badge-notify">3</span>
</a></li>
i dont know if a css problem or what, the button creates a blank space on navbar.
posibily the problem is
Firstly, buttons inside links are invalid HTML so either use just a link or just a button...not both.
You need to put the second span inside the button (or link) and the position it absolutely.
.btn-link {
position: relative;
}
.badge-notify {
background: red;
position: absolute !important;
top: -15px; /* adjust as required*/
right: 5px; /* adjust as required*/
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="nav navbar-nav navbar-center">
<li>
<button class="btn btn-lg btn-link">
<span class="glyphicon glyphicon-envelope"></span>
<span class="badge badge-notify">3</span>
</button>
</li>
</ul>
Related
I have a menu in my website which is not aligned.
Picture
How do I go about aligning all the text of nav menu with the text of the blue button on right? I have tried the following code which doesn't seem to work right.
HTML
<nav class="navbar bg-color3">
<div class="container-fluid">
<img src="/Content/images/uploads/photo-01.png" width="410" alt="PG Portal de Gastos" style="float: left; margin: 18px 10px 10px 0;">
<button class="round-toggle navbar-toggle menu-collapse-btn collapsed" data-toggle="collapse" data-target=".navMenuCollapse">
<span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
</button>
<div class="collapse navbar-collapse navMenuCollapse">
<div class="login-panel">
<ul id="nav-list" class="nav pull-right">
<li>Inicio</li>
<li>Beneficios</li>
<li> Funcionalides</li>
<li>Planes</li>
<li>Contacto</li>
<li class="sub-menu-parent">
<a class="btn " href="#">Iniciar SesiĆ³n <i class="icon right-icon icon-login"></i></a>
<ul class="sub-menu">
<li>
<a class="btn btn-primary" style="border: 1px solid transparent;" href="#Url.Action("Login", "Cuenta")">
Portal
</a>
</li>
<li>
<a class="btn btn-primary" style="border: 1px solid transparent;" href="http://web.com/">
Portal
</a>
</li>
</ul>
</li>
<a class="btn btn-primary" href="#Url.Action("Registrar", "Cuenta")">
Iniciar Prueba<i class="icon right-icon icon-download"></i>
</a>
</ul>
</div>
</div>
</div>
</nav>
You have to remove the padding on .navbar .nav li:
.navbar .nav li {
padding:0;
float:left;
}
At the moment there is a padding:5px which causes a gap aroud the buttons.
The problem is in the padding of the .navbar .login-panel .btn class. If you remove the padding there ( padding: 0 20px; ) the text is horizontally lined. If you want the padding in the rest of the menu make specific padding for each of the classes.
use padding instead of height for both (adjust padding-bottom and padding-top for height problems)
try in both blue and white space
I come to you because I'm pulling my hair out of my head on a design issue with bootstrap navbars.
I did a fixed top navbar with differents menu, one on the right and one on the left.
My CSS code turns the background of my links to the grey when the user hover them. But I notice that my menu items don't have the same height so when my pointer hover the smaller item, the new color doesn't fill the full height of the header bar.
This is some screenshots to help you :
And there is the code of my header bar :
<div class="container-fluid header-bar">
<div class="navbar-header">
<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>
<a class="navbar-brand" href="index.html">Admin Page</a>
</div>
<!-- /.navbar-header -->
<ul class="nav navbar-nav navbar-left">
<li>
<a href class=" profile_image" >
<img src="../../../images/user.png" class="img-circle" alt="profile-pic"> {{vm.account.name}}
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown" uib-dropdown="">
<a href class="dropdown-toggle lang_selector" uib-dropdown-toggle="">
<span class="flag-sm flag-sm-{{vm.defaultLang.flag}}"></span><span class="lang_desc">{{vm.defaultLang.text}}</span> <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu" uib-dropdown-menu="">
<li ng-repeat="lang in vm.langs"><a href class="lang_selector" ng-click="vm.defaultLang = lang"><span class="flag-sm flag-sm-{{lang.flag}}"></span><span class="lang_desc">{{lang.text}}</span></a></li>
</ul>
</li>
<li>
<a href="" ng-click="vm.logout()">
<md-icon class="li-icon-black material-icons" aria-label="logout">exit_to_app</md-icon>
</a>
</li>
</ul>
</div>
And there is the CSS code :
.smsmode-nav .navbar-header {
width: 250px;
}
.lang_selector > span {
vertical-align: middle;
}
.lang_desc {
margin-left: 8px
}
.navbar-nav > li > a.profile_image {
padding-top: 10px;
padding-bottom: 10px;
}
.profile_image > img {
width: 30px;
}
I know there is a story of padding but I try everything and I can't fix it. I'm desperated ! So I need your help please !
hi remove this css i hope you got your solutions
.lang_selector > span {
vertical-align: middle;
}
I have a div here which contains 3 dropdowns:
<div class="text-center container">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" id="make" type="button" data-toggle="dropdown"> Subject
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="makein">
<li>bmw</li>
<li>mercedes</li>
<li>mazda</li>
<li>ford</li>
<li>lada</li>
<li>audi</li>
<li>skoda</li>
<li>fiat</li>
</ul>
</div>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" id="year" type="button" data-toggle="dropdown"> Year
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="yearin">
<li>2016</li>
<li>2015</li>
<li>2014</li>
<li>2013</li>
<li>2012</li>
<li>2011</li>
<li>2010</li>
<li>2009</li>
</ul>
</div>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" id="level" type="button" data-toggle="dropdown"> Level
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="levelin">
<li>luxury</li>
<li>ordinary</li>
</ul>
</div>
</div>
I use the following to center the div in the middle of the screen centered:
.container{
width: 300px;
height: 300px;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.dropdown{
display: inline-block;
}
It also aligns my drop downs horizontally.
I locate my div in the middle of the screen using this custom css. I am wondering if there is a way to avoid using the custom css and do this same thing just purely using Bootstrap.
My aim is:
1: Locate the container in the center in the middle of the page.
2: Horizontally align the dropdowns.
Bootstrap shipped with container and text-center classes then why you are defining your own container class? Just include bootstrap files properly in your code and no need for this custom CSS.
text-center class will align your drop down in middle of screen and container class has fixed width with auto margin. Check jsFiddle
To achieve expected result , use below CSS to container
.container{
width: 300px;
height: 60%;
position: absolute;
top:20%;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
http://codepen.io/nagasai/pen/LkoLGw
There are no way in bootstrap to locate div in the middle of the screen.
you may check below custom css code:
.container {
position: absolute;
width: 100%;
top: 45%;
}
.dropdown {
display: inline-block;
}
I have a project where I have used a bootstrap navbar but broken it up into flexboxes in order to align the various parts per specification. I want to put a logo in the far left corner of the navbar, where navbar-brand is usually given, but I'm having no luck getting an image to show. The best I can do is get an image placeholder icon to show. Attached is an image of the navbar as it stands now.
The following is the HTML for the navbar:
<div class="container first-container">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container navcell flex-navbar">
<div class="navbar-brand">
<!--<a class="navbar-brand" href="#">-->
<img src="images/SST.jpg" class=" navbar-brand sst-image"></img>
<!--</a>-->
</div>
<button class="navitem navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navitem navbar-collapse collapse navbar-responsive-collapse">
<ul class="nav navcell navbar-nav">
<li class="active"><span class="navitem glyphicon glyphicon-home"></span> Home</li>
<li><span class="navitem glyphicon glyphicon-edit"></span> Services & Rates</li>
<li><span class="navitem glyphicon glyphicon-book"></span> Portfolio</li>
<li><span class="navitem glyphicon glyphicon-user"></span> About/Contact John</li>
<li><span class="navitem glyphicon glyphicon-log-in"></span> Log In</li>
</ul>
<form class="navcell navbar-form">
<input type="text" class="form-control" placeholder="Search" id="searchinput">
<button type="navbtm submit" class="btn btn-default">
<span class="navitem glyphicon glyphicon-search"></span>
</button>
</input>
</form>
</div><!-- Nav-collapse -->
</div><!-- Container -->
</nav>
</div><!--Container-->
The pertinent .css is
body {
margin-top:50px;
background: url('../images/marble.jpg') no-repeat center top scroll;
}
.container{
width: 100%;
}
.navbar-brand {
background-image: url('../images/SST.jpg') no-repeat;
position: relative;
}
.banner {
font-family: 'atlas_of_the_magiregular', cursive;
font-size: 1.7em;
line-height: 1.3em;
padding: 10px 8px;
margin: 10px 0px;
background-image: url('../images/Sic Semper Scroll.png') no-repeat;
background-position: 50% 50%;
position: relative;
}
I included the banner section in the .css to show how I've implemented the scroll image below the navbar. I've tried setting the brand logo to be an image in the HTML, a background image in the CSS, nothing. I can put text into the navbar-brand and set it's color, but I'm having no luck with my logo image. What can I try next?
The problem seems to be with the relative path you are using for the image.
If you use an image with an absolute URL it works fine. Try this to see what I mean:
<div class="navbar-brand">
<!--<a class="navbar-brand" href="#">-->
<img src="http://i.imgur.com/60PVLis.png" alt="" class="navbar-brand sst-image">
<!--</a>-->
</div>
If you want to use a relative path, you need to make sure it's leading to the folder that contains the image. In your CSS the path is ../images/SST.jpg, but in your HTML the path is images/SST.jpg. You need to find the right path.
As a side note, keep in mind that <img> is a void element. No closing tag is required. You can remove the </img>.
I have a drop down menu that opens a row of icons underneath it (see picture 1, names and pictures were removed to maintain privacy)
I am trying to make this menu to open to the right of choose child, and not underneath it (see picture 2, of what I am trying to get. the Images will open to the right of the drop down and not under it)
My current code is:
<div class="span4">
<div class="btn-group">
<a class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="#">
<h3>Choose Child</h3>
<img id="mainIcons" src="boyStudent.png" alt="boyStudent">
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<div class="btn-group">
<a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
<h5>A</h5>
<img id="mainIcons" src="boyStudent.png" alt="boyStudent"></a>
<a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
<h5>J</h5>
<img id="mainIcons" src="girlStudent.png" alt="girlStudent"></a>
</div>
</li>
</ul>
I tried to use the following example, that helps push the drop down to the left
how to make twitter bootstrap submenu to open on the left side?
but I could not figure out a way to use this to what I am looking to do
Thanks
How does this look:-
Demo
Demo2 Submenu dropping down.
<div class="span4">
<div class="btn-group"> <a class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="#">
<h3>Choose Child</h3>
<img id="mainIcons" src="boyStudent.png" alt="boyStudent">
<span class="right-caret right"></span>
</a>
<ul class="dropdown-menu rightMenu">
<li>
<div class="btn-group"> <a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
<h5>A</h5>
<img id="mainIcons" src="boyStudent.png" alt="boyStudent"></a>
<a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
<h5>J</h5>
<img id="mainIcons" src="girlStudent.png" alt="girlStudent"></a>
</div>
</li>
</ul>
</div>
css
.rightMenu {
position:relative;
float:right;
}
.right-caret {
border-bottom: 4px solid transparent;
border-top: 4px solid transparent;
border-left: 4px solid #000000;
display: inline-block;
height: 0;
opacity: 1;
vertical-align: top;
width: 0;
}
.right
{
float:right;
}
Just add the class "pull-right" into the <ul class="dropdown-menu"> this way...
<li class="dropdown">
<a class="dropdown-toggle" href="#">Link</a>
<ul class="dropdown-menu pull-right">
<li>...</li>
</ul>
</li>
I just add this class to the dropdown-menu:
.rightMenu {
position:absolute;
float:right;
top: 0;
left: 160px;
}
And it aligns perfectly.
To those who may find this page in the future, the now official way of doing this is with adding the .dropdown-menu-right class to your dropdown list.