My problem is this: when inserting a new button in navbar the User Name goes to the bottom line. My goal is for everything to be aligned on the same line.
I have already used display: inline-block and flex-direction: row but it did not work. Can someone help me?
HTML
<div class="col-md-10 p0">
<div class="collapse navbar-collapse" id="min_navbar">
<ul class="nav navbar-nav navbar-right">
<li>Home</li>
<li>Tabelas</li>
<li>Registo</li>
<li class="dropdown submenu">
Quem Somos
<ul class="dropdown-menu other_dropdwn">
<li>About Us</li>
<li>About Us-2</li>
</ul>
</li>
<li class="dropdown submenu">
Serviços
<ul class="dropdown-menu other_dropdwn">
<li>Services</li>
<li>Services-2</li>
</ul>
</li>
<li class="dropdown submenu">
Notícias
<ul class="dropdown-menu">
<li>Últimas Notícias</li>
<li>Notícia Singular</li>
</ul>
</li>
<li>Contactos</li>
<li>Login</li>
<li><i class="fa fa-search"></i></li>
<li class="dropdown submenu">
<img src="https://cdn4.iconfinder.com/data/icons/user-avatar-flat-icons/512/User_Avatar-44-512.png" class="rounded circle" style="width: 50px; height: 50px;" /> Nome
<ul class="dropdown-menu">
<li>Perfil</li>
<li>Logout</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
Your navbar may be too big, so it won't work. But, if it is not too big, this might work:
Here, add a class. I chose floater:
<li class="dropdown submenu floater">
<img src="https://cdn4.iconfinder.com/data/icons/user-avatar-flat-icons/512/User_Avatar-44-512.png" class="rounded circle" style="width: 50px; height: 50px;" /> Nome
<ul class="dropdown-menu">
<li>Perfil</li>
<li>Logout</li>
</ul>
</li>
In your CSS, do:
.floater {
float: right;
}
You may have some extra margin or padding somewhere in your code, so I would check that.
Please, consider moving from float to flexbox or grid to set position of elements!* We have "killer-features" in CSS nowadays, like Flexbox or even better CSS Grid (but there's some lacks of browser support). Yep, it's quite difficult to handle it at the begining, but when you'll understand how to roll with it - you'll love it!
I have already used display: inline-block and flex-direction: row but
it did not work. Can someone help me?
You can't combine display: inline-block with flex-direction, because you're trying to combine flex with blocks. You should use display: inline-flex instead.
HTML Markup:
<ul class="d-flex">
<li>Lorem, ipsum.</li>
<li>Ad, quas.</li>
<li>Recusandae, minima.</li>
<li>Tempore, sint.</li>
<li>Consequuntur, porro.</li>
<li>Ipsum, at!</li>
</ul>
SCSS Markup:
.d-flex {
display: inline-flex;
}
ul {
li {
display: inline-flex;
margin: 0 10px;
padding: 2px 8px;
border: 1px solid black;
border-radius: 4px;
}
}
Here you can try with flex:
https://codepen.io/dstolarski/pen/XOYEwR
Related
Currently, the line dividing the content and the side menu stops at the side menu's content. However, the content will be longer than the side menu. It makes the page uneven. I tried manipulating the page-content d-flex but i am not successful.
Using template from https://bootstrapious.com/p/admin-template
Below is the code for the side menu
<div class="page-content d-flex align-items-stretch">
<nav class="side-navbar">
<!-- Sidebar Navidation Menus-->
<ul class="list-unstyled">
<li class="active"> <i class="icon-home"></i>Home </li>
<li><a routerLink="/dashboard"> <i class="icon-picture"></i>Dashboard</a></li>
<li><a routerLink="/tasknotification"> <i class="icon-padnote"></i>Task Management</a></li>
<li><a routerLink="/candidate"> <i class="icon-user"></i>Candidate Management </a></li>
<li><a routerLink="/job"> <i class="icon-interface-windows"></i>Job Management</a></li>
<li><a href="#exampledropdownDropdown" aria-expanded="false" data-toggle="collapse"> <i
class="icon-interface-windows"></i>Example dropdown </a>
<ul id="exampledropdownDropdown" class="collapse list-unstyled ">
<li>Page</li>
</ul>
</li>
</ul>
</nav>
nav.side-navbar {
text-align: left;
min-width: 250px;
}
.page-content {
min-width: calc(100% - 250px);
}
This way side-menu won't collapse. As I saw your fiddle I think that might work
modify media query
#media (max-width: 1199px)
nav.side-navbar {
text-align: center;
overflow: hidden;
}
I'm using Bootstrap to create a navbar in the top of the page, but i'm facing some problems:
After opening the navbar dropdown, I need to have a option list, and a image positioned to the right of the list. This image needs to have the same height of the list, just like in the following image (in portuguese, but easily understandable).
I achieved this setting a fixed height and width on the image, but the list can grow up and isn't a good option adjust it manually.
Another solution is to insert a div containing the list and the image, and set the image size to 100%, but when I do this, the dropdown isn't achieved anymore (I think i'm breaking the structure that Bootstrap uses to toggle the dropdown, am I right?).
How can I achieve this solution?
<div id="navbar" class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav top-elements">
<li id="dropdown-produtos" class="dropdown">
Nossos Produtos<span class="caret top-caret"></span>
<!-- div was here --> <ul class="dropdown-menu dropdown-menu-produtos">
<li class="dropdown-item-active">
texto1
<ul class="dropdown-menu img-dropdown">
<img src="assets/img.png">
</ul>
</li>
<li class="dropdown-item">
texto2
</li>
<li class="dropdown-item">texto3</li>
<li class="dropdown-item">texto4</li>
<li class="dropdown-item">texto5</li>
</ul>
</li>
</ul>
</div>
This should work:
<ul class="nav navbar-nav">
<li>Elemento 1</li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">DropDown<span class="caret"></span></a>
<ul class="dropdown-menu another-class">
<!-- ROW -->
<div class="col-md-12">
<!-- Column 1 -->
<div class="col-md-6">
<ul class="list-unstyled">
<li>Texto 1</li>
<li>Texto 2</li>
<li>Texto 3</li>
</ul>
</div>
<!-- Column 2 -->
<div class="col-md-6">
<div class="drop-image">
<img src="./img/img.jpg" class="img-responsive" />
</div>
</div>
</div>
</ul>
</li>
<li>Elemento 2</li>
<li>Elemento 3</li>
</ul>
Basically what I'm doing is create a div with a full width inside the dropdown element that comes as default in Boostrap. Inside this Full width row I create two columns with bootstrap col-md-6 class (you can do this with col-lg or col-sm or col-xs too) Inside this columns I add my content normally.
I created a class in the column 2 named "drop-image"; use this class to modify the img inside.
Hope it helps!
Btw, don't forget to style your dropdown (in the example I mark it with a class named another-class) so you define the position and width.
This might solve your problem, it's based off this plugin Yamm3!. See example Snippet.
Change this CSS rule if you need to make the dropdown wider because of the length of the link text. >
.list-unstyled, .list-unstyled ul {
min-width: 180px
}
body {
padding-top: 60px;
color: #666;
}
/* menu styes */
.list-unstyled,
.list-unstyled ul {
min-width: 180px
}
.list-unstyled > li {
padding-top: 10px;
}
.list-unstyled > li > a {
color: #555;
text-decoration: none;
}
.yamm .nav,
.yamm .collapse,
.yamm .dropup,
.yamm .dropdown {
position: static;
}
.yamm .container {
position: relative;
}
.yamm .dropdown-menu {
left: auto;
background: #f5f5f5;
}
.yamm .yamm-content {
padding: 0 30px 10px 30px;
}
.yamm .yamm-content .nav-title {
margin-left: 15px;
}
.yamm .dropdown.yamm-fw .dropdown-menu {
left: 0;
right: 0;
}
#media (max-width: 767px) {
.yamm-content .list-unstyled > li img {
margin-top: -180px;
float: right;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar yamm navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" data-toggle="collapse" data-target="#navbar-collapse-1" class="navbar-toggle"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>Grande Menu
</div>
<div id="navbar-collapse-1" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<!-- Classic list -->
<li class="dropdown">Nossos Produtos<b class="caret"></b>
<ul class="dropdown-menu">
<li>
<!-- Content container to add padding -->
<div class="yamm-content">
<div class="row">
<h4 class="nav-title"><strong>A partida de um</strong></h4>
<ul class="col-sm-4 list-unstyled">
<li>Vinculando um
</li>
<li>Ligando dois
</li>
<li>Ligação de três
</li>
<li>Quatro ligação
</li>
<li>Ligação cinco
</li>
<li>Seis ligação
</li>
</ul>
<ul class="col-sm-2 list-unstyled">
<li>
<img src="http://placehold.it/150x150/ff0/fff">
</li>
</ul>
</div>
</div>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<!-- Classic list -->
<li class="dropdown">Nossos Produtos Dois<b class="caret"></b>
<ul class="dropdown-menu">
<li>
<!-- Content container to add padding -->
<div class="yamm-content">
<div class="row">
<h4 class="nav-title"><strong>A partida de um</strong></h4>
<ul class="col-sm-4 list-unstyled">
<li>Vinculando um
</li>
<li>Ligando dois
</li>
<li>Ligação de três
</li>
<li>Quatro ligação
</li>
<li>Ligação cinco
</li>
<li>Seis ligação
</li>
</ul>
<ul class="col-sm-2 list-unstyled">
<li>
<img src="http://placehold.it/150x150/ff0/fff">
</li>
</ul>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="alert alert-warning">Olá</div>
</div>
I am using Twitter Breadcrumb in my html page. But the breadcrumb keeps appearing in a new line. How can I make it come next to the glyphicon?
This is the div section:
<div class="col-md-3 well pre-scrollable scroll-pane">
<span class="glyphicon glyphicon-folder-close"></span>
<ul class="breadcrumb list-unstyled">
<li ng-repeat="crumb in breadcrumb track by $index">
{{crumb}}
</li>
</ul>
<hr>
<p>
<ul ng-repeat="node in nodes" class="list-unstyled">
<li ng-repeat="value in node">{{value}}</li>
</ul>
</p>
</div>
How it looks now:
There are unwanted spaces in the top and bottom. But I want the list to appear next to the glyphicon as if they are in a new line.
Just add some CSS inline. <ul> elements are automatically block-level elements. I believe that Bootstrap automatically adds glyphicons to be display: inline-block as well so it can apply with and margins to the icon.
Fiddle for you
span.glyphicon-folder-close,
ul.breadcrumb {
display: inline;
}
<div class="col-md-3 well pre-scrollable scroll-pane">
<span class="glyphicon glyphicon-folder-close"></span>
<ul class="breadcrumb list-unstyled">
<li>node1
</li>
<li>node2
</li>
<li>node3
</li>
<li>node4
</li>
</li>
</ul>
.....
.....
Addition:
Here's another way of doing it. Wrap the span and ul in it's own separate container so they float together. You have to remove the padding for the ul.breadcrumb as it's auto applied.
Add containers fiddle
ul.breadcrumb {
padding: 0;
}
<div class="col-md-3 well pre-scrollable scroll-pane">
<div class="col-xs-1">
<span class="glyphicon glyphicon-folder-close"></span>
</div>
<div class="col-xs-11">
<ul class="breadcrumb list-unstyled">
<li>node1
</li>
<li>node2
</li>
<li>node3
</li>
<li>node4
</li>
</li>
</ul>
</div>
....
....
Addition #3 (worked best for OP)
Here's an even better way. Just use psuedo selector for the breadcrumb and remove the span altogether. Also remove the <hr> tag and add border to the breadcrumb itself
Fiddle w/ psuedo
ul.breadcrumb {
position: relative;
padding-bottom: 10px;
border-bottom: 1px solid #ccc;
}
ul.breadcrumb:before {
position: absolute;
content: '\e117';
font-family: 'Glyphicons Halflings';
left: -10px;
top: 8px;
width: 20px;
height: 20px;
}
<div class="col-md-3 well pre-scrollable scroll-pane">
<ul class="breadcrumb list-unstyled">
<li>node1
</li>
<li>node2
</li>
<li>node3
</li>
<li>node4
</li>
</li>
</ul>
....
....
It may be due to the parent div width is not enough for show all.
I am looking to have side-ways dropdown menu that could be clicked. Upon hovering over the list items, it that list items has any nested li items, it will show up.
Here is my current code. you can paste it in http://www.bootply.com/ to see how it looks. It currently is very bad. it is displaying everything at the same time. and even one of the items is hidden behind another list item.
I tried to follow this post. but I could not get it working. I am using bootstrap 3 in my HTML. so if there is a way to do it with bootstrap3 , that would be fine too.
Here is my html with inline css at the end:
<div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation">
<div class="list-group">
<li id="settings" class="list-group-item">toyota highlander
<ul id="test">
<li>atlanta</li>
<li>austin</li>
<li>boston</li>
<li>chicago</li>
<li>seattle</li>
</ul>
</li>
<li>honda fit </li>
<li id="settings" class="list-group-item ">ford explorer
<ul id="test">
<li>raleigh</li>
<li>sacramento</li>
<li>sandiego</li>
<li>seattle</li>
</ul>
</li>
</div>
</div><!--/span-->
</div><!--/row-->
<style>
li#settings {
position:absolute;
overflow: visible;
}
li#settings:hover > ul {
cursor:pointer;
display:block;
}
ul#test {
display: none;
white-space: nowrap;
list-style: none;
position: absolute;
top:34px;
}
</style>
In this bootstrap template, there are links on right side of page, as you hover over each link, I want to display li items with-in that link. if there are no li-items, the link itself will be clickable
EDIT:
latest trial here:
<div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation">
<div class="btn-group-vertical">
<div id="sidebar" class="sidebar-nav span3">
<ul class="nav nav-tabs nav-stacked">
<ul class="dropdown-menu" style="display: block; position: static; margin-bottom: 5px; *width: 180px;">
<li class="dropdown-submenu active "> <a tabindex="-1" href="#">toyota highlander </a>
<ul class="dropdown-menu">
<li>atlanta</li>
<li>austin</li>
<li>boston</li>
<li>chicago</li>
<li>seattle</li>
</ul>
</li>
<li class="nav-menu">honda fit </li>
<li class="dropdown-submenu "> <a tabindex="-1" href="#">ford explorer </a>
<ul class="dropdown-menu">
<li>raleigh</li>
<li>sacramento</li>
<li>sandiego</li>
<li>seattle</li>
</ul>
</li>
</ul>
</ul>
</div>
</div>
</div>
UPDATE: CHECK this FIDDLE for my updated answer. I've used Bootstrap 3 this time.
note: I was searching how to move the arrow to the left like the sub-menu but I can't find the answer. I hope this still helps.
I've research and found out the dropdown-submenu is not supported on Bootstrap 3 anymore. Please see the accepted answer. It might help you.
Is THIS what you are trying to do?
Dropdown submenu CSS for Bootstrap 3:
.dropdown-submenu{position:relative;}
.dropdown-submenu>.dropdown-menu{top:0;left:100%;margin-top:-6px;margin-left:-1px;-webkit-border-radius:0 6px 6px 6px;-moz-border-radius:0 6px 6px 6px;border-radius:0 6px 6px 6px;}
.dropdown-submenu:hover>.dropdown-menu{display:block;}
.dropdown-submenu>a:after{display:block;content:" ";float:right;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#cccccc;margin-top:5px;margin-right:-10px;}
.dropdown-submenu:hover>a:after{border-left-color:#ffffff;}
.dropdown-submenu{float:none;}.dropdown-submenu>.dropdown-menu{left:-100%;margin-right:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px;}
.sidebar{float:right;margin-right:20px;}
Why don't you use the Button Groups? The vertical variation looks similar to what you are doing.
<div class="btn-group-vertical">
<button type="button" class="btn btn-default">1</button>
<button type="button" class="btn btn-default">2</button>
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Dropdown link</li>
<li>Dropdown link</li>
</ul>
</div>
</div>
I cant post an image, but i have a navigation menu on a site im coding. Im trying to crush the site for mobile, but when I do this the li menu drops under. However I want it to center.
This is the code i have so far
#media (min-width:768px){
}
<ul class="nav nav-tabs nav-menu img-centered">
<li class="nav-link-green">Home</li>
<li class="nav-link-yellow">About Us</li>
<li class="nav-link-red">Parents & Carers</li>
<li class="nav-link-blue">Young People</li>
<li class="nav-link-purple">News & Updates</li>
<li class="nav-link-green">Contact Us</li>
<li class="nav-link-blue dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" role="button" href="#">Publications <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li>Safeguarding Library</li>
<li class="nav-divider"></li>
<li>Learning Zone</li>
<li class="nav-divider"></li>
<li>TSCB Publications</li>
</ul>
</li>
</ul>
I hope this makes sense. If you need anything more please let me know. This is my first post
Did you try the class .collapse on your nav?
like here: http://getbootstrap.com/components/#navbar
Ok, worked this out. Just added this code to the css.
ul {
display: block;
text-align: center;
}
li {
display: inline-block;
position: relative;
text-align: center;
float: none;
}
This makes it happen.