Bootstrap 4 multilevel dropdowns are slightly misaligned - css

I have been working with this Bootstrap 4 snippet.
I have adjusted it slightly (so far) but am experiencing a slight drop on each of the subsequent dropdowns.
Here is the css as it stands:
.menu-area {
background: #d61a5e
}
.mainmenu ul li {
position: relative;
}
.mainmenu .dropdown-menu {
margin: 0;
border-radius: 0;
}
.mainmenu a, .navbar-default .navbar-nav > li > a, .mainmenu ul li a, .navbar-expand-lg .navbar-nav .nav-link {
color: #aaa;
font-size: 16px;
text-transform: capitalize;
padding: 16px 15px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
display: block !important;
}
.mainmenu .active {
color: #fff;
background: #222;
}
/******************************Drop-down menu work on hover**********************************/
.mainmenu {
background: none;
border: 0 solid;
margin: 0;
padding: 0;
min-height: 15px;
width: 100%;
}
#media only screen and (min-width: 767px) {
.mainmenu .collapse ul li:hover > ul {
display: block;
}
.mainmenu .collapse ul ul {
position: absolute;
top: 100%;
left: 0;
min-width: 250px;
display: none;
}
/*******/
.mainmenu .collapse ul ul li {
position: relative
}
.mainmenu .collapse ul ul li:hover > ul {
display: block
}
.mainmenu .collapse ul ul ul {
position: absolute;
top: 0;
left: 100%;
min-width: 250px;
display: none
}
/*******/
.mainmenu .collapse ul ul ul li {
position: relative
}
.mainmenu .collapse ul ul ul li:hover ul {
display: block
}
.mainmenu .collapse ul ul ul ul {
position: absolute;
top: 0;
left: 100%;
min-width: 250px;
display: none;
z-index: 1
}
}
#media only screen and (max-width: 767px) {
.navbar-nav .show .dropdown-menu .dropdown-menu > li > a {
padding: 16px 15px 16px 35px
}
.navbar-nav .show .dropdown-menu .dropdown-menu .dropdown-menu > li > a {
padding: 16px 15px 16px 45px
}
}
Having followed the snippet I am not that sure as to why each level is slightly lower than the last. I think its to do with the hover section of the css but I do not know how to adjust this to force it to level up..
I am hoping someone might know how to fix this.
EDIT
Here is the Html for the page.
The thing about Aurelia is that it tries to get out of the way of javascript which might help with those that know JS well.
<template>
<require from="./navmenu.scss"></require>
<require from="./activeRoute"></require>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mainmenu mr-auto">
<a class="navbar-brand" href="#/home">JobsLedger</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li repeat.for="route of router.navigation">
<a href.bind="route.href" if.bind="!route.settings.nav" class=" ${route.href == topUrl ? 'active' : ''}">
${route.title}
</a>
<a href.bind="route.href" if.bind="route.settings.nav" class="dropdown-toggle ${route.href == topUrl ? 'active' : ''}" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
${route.title}
</a>
<ul if.bind="route.settings.nav" class="dropdown-menu" aria-labelledby="navbarDropdown">
<li repeat.for="menu of route.settings.nav">
<a href.bind="menu.href" if.bind="!menu.settings.nav" class="dropdown-menu-link">
${menu.title}
</a>
<a href.bind="menu.href" if.bind="menu.settings.nav" class="dropdown-toggle dropdown-menu-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
${menu.title} <span class="caret-right"></span>
</a>
<ul if.bind="menu.settings.nav" class="dropdown-menu" aria-labelledby="navbarDropdown">
<li repeat.for="subMenu of menu.settings.nav">
<a href.bind="subMenu.href" if.bind="!subMenu.settings.nav" class="dropdown-menu-link">
${subMenu.title}
</a>
<a href.bind="subMenu.href" if.bind="subMenu.settings.nav" class="dropdown-toggle dropdown-subMenu-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
${subMenu.title} <span class="caret-right"></span>
</a>
<ul if.bind="subMenu.settings.nav" class="dropdown-menu" aria-labelledby="navbarDropdown">
<li repeat.for="lowestSubMenu of subMenu.settings.nav">
<a href.bind="lowestSubMenu.href" if.bind="!lowestSubMenu.settings.divider" class="dropdown-menu-link">
${lowestSubMenu.title}
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right mr-auto">
<li repeat.for="route of router.navigation" if.bind="route.settings.pos == 'right'" class="${ row.isActive ? 'link-active' : '' }">
<a href.bind="route.href" if.bind="!row.settings.nav">${ row.title }</a>
<a href.bind="route.href" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"
if.bind="route.settings.nav">
${row.title}
<span class="caret"></span>
</a>
<ul if.bind="route.settings.nav" class="dropdown-menu">
<li repeat.for="menu of row.settings.nav">
<a href.bind="menu.href">${menu.title}</a>
</li>
</ul>
</li>
<li><a>Welcome ${userName}</a></li>
<li>Log Out</li>
</ul>
</div>
</nav>
</template>

Related

bootstrap 5 dropdown-menu navbar streches strangly when hover on dropdown-ul-items

My bootstrap dropdown Navbar menu acts strangely on small screens. As shown n the images below, hovering above dropdown menus pushes the other UL section below or to the side.
I struggle to figure out how to solve it so it can be displayed similarly to the way it on large screens.
My menu is composed  of three sections.
Utilities (ul section that regroups Contact, Languages, LogIn, Search components)Brand+logoNavigation.
In my Sass file, I tried with the following code to displays the dropdown-menu on a higher z-index on small screens, the result remained the same.
#media (max-width: 576px) {
.dropdown-toggle ul {
z-index: 99;
}
}
Below you can find Navbar code and my styling.
I tried to keep it as short as possible.
Any advise on how I advance would be highly appreciated. .
<!-- Navbar-->
<nav class="navbar fixed-top navbar-expand-lg navbar-light bg-light">
<div class="container-fluid justify-content-between">
<!--Utilities Section-->
<ul class='navbar-nav flex-row components order-sm-2'>
...
<!--Search section--><li class="nav-item dropdown">
<a class="nav-link" href="/search/"><i class="fas fa-search" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false">
</i></a>
</li><!--End Search section--><!--Language section--><li class="nav-item dropdown">
<span class="nav-link dropdown-toggle badgeClass" type="button" id="dropdownMenuButton3" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa fa-globe" id="lang1">
</i>
<span class="badge rounded-pill bg-danger">{{LANGUAGE_CODE|capfirst}}</span>
</span>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownMenuButton3">
...
<li class=""><a class="dropdown-item active" href="page_url" hreflang="{{ language_code }}">
{{ language.name_local }} ({{ language.code }})
</a></li> ...<li class="">...
</ul>
</li>
...Idem for
'User Section''Contact Section'
</ul>
<!--End Utilities section-->
<!--Header section, logo title-->
<a class="navbar-brand ms-3" href="/">{{ logo.name }} {% image logo. fill-50x50 %}</a>
<--Navigation section-->
...<!--End Navigation section -->
</div>
</nav>
Sass/CSS/* the navigation menu */
a.menuitem {
font-size: 1.2em;
font-weight: bold;
}
.nav-link, .fa-search, .nav-language{
color: $secondary !important;
}
.nav-link:hover, .fa-search:hover, .nav-language:hover {
color: $primary !important;
}
.nav-item.active {
border-bottom:2px solid $primary;
color: red !important;
}
/* slightly enlarge the image on hover */
a.menuitem .image-menu {
transition: transform 300ms;
}
a.menuitem:hover .image-menu {
transform: scale(1.1);
}
a.menuicon:hover {
text-decoration: none;
}
a.dropdown-menu {
min-width: 40px;
}
/* for the logo */
.navbar .navbar-brand {
font-family: 'Mochiy Pop P One', sans-serif!important;;
font-size: 30px !important;
color: $primary !important;
}
.nav-link .fa {
font-size:150%;
font-weight:100;
}
.navbar .fa {
font-size:2rem;
}
/*dropdown menu*/
.dropdown-submenu {
position: relative;
}
.submenu .dropdown-menu {
top:20px;
left:100%!important;
margin-top: -1px;
}
.dropdown-menu li a:hover {
color:$primary!important;
}
.navbar-nav li:hover > ul.dropdown-menu {
display: block;
}
.dropdown-menu > li:hover > .submenu{ display: block; }
.dropdown-item {
width:auto;
}
/* different color for the parent item in the dropdown-menu */
.navbar-nav li a b {
color:$danger;
}
.navbar-nav li a b:hover {
color:$warning;
}
/* components class to hide the dropdown-toggle for utilities items*/
.components .dropdown-menu-end {
right: 0;
left: auto;
}
.components .dropdown-toggle::after {
content: none;
}
/*language badge*/
.nav-item .badgeClass{
position: relative;
}
.nav-item .badgeClass span{
position: absolute;
top: 0px;
right: 0px;
display: block;
font-size:.4em;
}

How to align Bootstrap 4 navbar items to bottom

I'm trying to align the text of the navbar items lowerin bootstrap 4. My idea was to align them to the bottom of the ul and then position the ul but I seem to fail to do both. The goal is to have the text (approximately) at the same height of the brand like this:
I have found some questions but most of them are for bootstrap 3 or don't work for some reason I don't understand.
This is example html:
<nav class="navbar navbar-expand-md navbar-dark bg-primary fixed-top">
<a class="navbar-brand" style="font-family: sans-serif; font-weight: 800; font-style: italic; font-size:xx-large;">Brand</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="navbar-nav ml-auto">
<li class="nav-item" >
<p style="vertical-align:bottom;" >Test</p>
</li>
<li class="nav-item<?php addActiveClass('/index.php'); ?>">
<a class="nav-link" href="index.php">Test</a>
</li>
<li class="nav-item d-none d-md-block"><img src="" id="profileImage" height="40" width="40" style="margin-right: 10px; border-radius: 5px;"></li>
</ul>
</div>
I use this bootstrap theme and example css:
.navbar
{
padding:0rem 0.75rem;
}
.navbar-brand
{
padding: 0;
margin:0;
}
.navbar-nav > li
{
line-height: 36px;
padding: 0;
margin: 0;
background: red;
}
.navbar-nav > li > a
{
padding: 0;
margin: 0;
background: red;
vertical-align: bottom;
}
.navbar-nav > li > p
{
padding: 0;
margin: 0;
background: yellow;
vertical-align: bottom;
}
A complete example is available here:
https://jsfiddle.net/d6n5z3gb/8/
Add align-items-end to the navbar-nav to align the items to the bottom...
<ul class="navbar-nav align-items-end ml-auto">
<li class="nav-item" >
</li>
</ul>
And, remove the custom line-height...
.navbar-nav > li > a
{
padding: 0;
margin: 0;
background: red;
vertical-align: bottom;
}
Update on Codeply: https://www.codeply.com/go/usR58ejrtg

How to make all navbar <li>s the same width

I am using Angular 4, Bootstrap 4 alpha 6 (css). I am trying to make each <li> the equal width (not 100% of the navbar). I was trying to use flex box but I cant get it to make them all equal.
I've tried several ways but each time the items will all be a fixed width but not the same width.
Heres an example of what I'm trying to do
[ ---item 1--- | ---item 2--- | ---item 3--- ]
HTML
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ng-container *ngIf="isLoggedIn">
<span class="navbar-text"> </span>
<ul class="nav navbar-nav ">
<li class="nav-item active">
<a class="nav-link" href="#">Dashboard <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="profileDropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
My Account
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item">My Account</a>
<a class="dropdown-item">My Account</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="accountDropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Profile
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" [routerLink]="['/profile', 'view']">My Account</a>
<a class="dropdown-item" [routerLink]="['/profile']">Edit my Profile</a>
</div>
</li>
</ul>
</ul>
</div>
</nav>
CSS
nav ul{
list-style: none;
margin: 0 2px;
padding: 0;
display: flex;
justify-content: space-around;
}
nav li{
width: 100%
}
.nav.navbar-nav > li{
border-right: 2px solid white;
}
EDIT: This works but I would prefer to use flex so that its done automatically
.nav.navbar-nav > li{
border-right: 2px solid white;
width: 200px;
max-width: 200px;
text-align: center;
}
Other ways I've tried
1)
.navbar ul.nav {
!*margin: 0;*!
display: table;
width: 100%;
!*direction: rtl;*!
table-layout: fixed;
margin:0;
padding:0;
}
.navbar ul.nav li {
!*float: right;*!
display: table-cell;
width: 20%;
!*float: none;*!
text-align: center;
!*direction: rtl;*!
}
.navbar .nav > li:hover {
background-color: #808080
}
.navbar .nav li:first-child a {
!*border-left: 0;*!
!*border-radius: 3px 0 0 3px;*!
}
.nav.navbar-nav > li{
!*width: 10%;*!
border-right: 2px solid white;
}
2)
nav {
text-align: center;
margin: 20px 0 0 ;
padding: 10px 0;
}
nav ul{
list-style: none;
margin: 0 2px;
padding: 0;
}
nav li {
display: inline-block;
padding: 5px 5px;
}
nav a {
font-weight: normal;
padding: 10px 5px;
}
Use calc() Basically by dividing 100% width by 3 each li will be 1/3 in width. Next you can set each "a" to 100% (width will be 100% of parent) and display:inline-block (so that width takes effect.
nav li{
width: calc(100% / 3);
}
I really don't see how you can get them to be the same size without giving your <nav> some kind of width. However, if you do give it a width, you can get all your child elements to be the same width using a combination of display: table; and display: table-cell. It's all the niceties of <table> without the syntactic commitment.
nav {
width: 50%;
position: relative;
}
nav ul {
display: table;
padding: 0;
margin: 0;
width: 100%;
}
nav ul li {
text-align: center;
display: table-cell;
border: 1px solid black;
}
<nav>
<ul>
<li>Fizz</li>
<li>Buzz</li>
<li>Foo</li>
</ul>
</nav>

Bootstrap 3: How to get other collapsed navbar links under the screen?

I have a navbar with many links/options:
When I collapsed it, some options are totally off the screen and I can't click on them:
In the pic, I can see link 4, but not link 5 and link 6.
Using a dropdown menu will do the same thing.
.navbar {
border: 0;
border-bottom: 1px solid #FFF;
background-color: #111 !important;
border-radius: 0px;
}
/* Adjust Toggle button */
.navbar-toggle {
margin-top: 18px;
}
/* Adjust Navbar Height */
.navbar-brand,
.navbar-nav li a {
padding-top: 0;
}
.navbar-brand,
.navbar-nav li a {
color: #FFF !important;
line-height: 70px;
height: 70px;
}
.navbar-brand {
color: #0CF !important;
}
.navbar-brand:hover,
.navbar-nav li a:hover {
background-color: #06C !important;
color: #0f9 !important;
}
.dropdown-menu > li > a {
line-height: 40px;
height: 40px;
}
.navbar-nav .open .dropdown-toggle {
background-color: #222 !important;
}
.navbar div ul li .dropdown-menu {
background-color: #222;
border-top: 2px solid #09f;
}
/* Nav Affix */
nav.affix {
position: fixed;
top: 0;
width: 100%;
z-index:10;
}
.affix + .container {
padding-top: 90px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.
<nav class="navbar navbar-default" data-spy="affix" data-offset-top="308">
<div class="container">
<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="#">
<i class="fa fa-adjust" aria-hidden="true"></i>
Brand
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-left">
<li>Storyline</li>
<li>Characters</li>
<li>Gallery</li>
<!--li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Misc<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>About</li>
<li>Contact</li>
<li>Other</li>
</ul>
</li-->
<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>
</div>
</nav>
<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.
<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.
<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
Something is wrong with your javascript probably. I see there is class .affix-top getting added to the .navbar .navbar-default. Remove that and your nav will scroll properly.

how to align social media icons in ul using bootstrap3

I am using navbar from Bootstrap3. There I just placed 2 links and social media icons. When the toggle-button is pressed I need to have the social media links content centered when the viewport is a smaller device like a phone or tablet. In my snippet the social links appeared to the left. Any help will be greatly appreciated.
<!-- Placed at the end of the document so the pages load faster -->
< script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" > < /script>
<!-- Latest compiled and minified JavaScript -->
<script src="https:/ / maxcdn.bootstrapcdn.com / bootstrap / 3.3.5 / js / bootstrap.min.js "></script>
/*css plugin for jquery content*/
.contenthover {
padding: 20px 20px 10px 20px;
}
.contenthover,
.contenthover h3,
contenthover a {
color: #fff;
}
.contenthover h3,
.contenthover p {
margin: 0 0 10px 0;
line-height: 1.4em;
padding: 0;
}
.contenthover a.mybutton {
display: block;
float: left;
padding: 5px 10px;
background: #3c9632;
color: #fff;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
.contenthover a.mybutton:hover {
background: #34742d
}
/*website*/
body {
margin: 0px;
padding: 0px;
font-family: "Gotham SSm A", "Gotham SSm B", sans-serif;
font-weight: 300;
}
.navbar-text {
margin: 0px;
}
.navbar-text > i {
color: inherit;
text-decoration: none;
}
/****************modifying bootstrap***********************/
.navbar-default {
background-color: #fff;
margin-bottom: 0px;
}
#mylinks {
display: inline;
}
#centered li {
text-align: center;
}
.nav-pills {
padding-top: 5px;
margin-left: 0px;
}
#cont-socialmedia {
margin: 0px;
padding: 0px;
text-align: center;
}
#main_cont {
Padding-top: 15px;
Padding-bottom: 15px;
background-color: pink;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: blue;
/*Sets the text hover color on navbar*/
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: rgb(84, 5, 29);
/*BACKGROUND color for active*/
background-color: white;
}
.nav > li > a:hover,
.nav > li > a:focus {
text-decoration: none;
background-color: gray;
/*Change rollover cell color here*/
}
.navbar-default .navbar-nav > li > a {
color: rgb(84, 5, 29);
/*Change active text color here*/
}
<head>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Social icons -->
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<!--toggle-->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#mylinks" 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>
<!--brand-->
<a class="navbar-brand" href="#">MILY VIDAL</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-right" id="mylinks">
<ul class="nav navbar-nav" id="centered">
<li class="active">Portfolio<span class="sr-only">(current)</span>
</li>
<li>Contact
</li>
</ul>
<!--testing new way to put smedia-->
<ul class="nav navbar-nav navbar-right nav-pills">
<li>
<i class="fa fa-linkedin"></i>
</li>
<li>
<a href="http://twitter.com/" class="btn btn-social-icon btn-twitter">
<i class="fa fa-twitter"></i>
</a>
</li>
<li>
<a href="http://www.linkedin.com/in/" class="btn btn-social-icon btn-linkedin">
<i class="fa fa-linkedin"></i>
</a>
</li>
<li>
<a href="https://github.com/broadmarkio" class="btn btn-social-icon btn-github">
<i class="fa fa-github"></i>
</a>
</li>
</ul>
<!--
<div class="navbar-text">
<a class="btn btn-social-icon" title="LinkedIn" href="#"><span><i class="fa fa-linkedin"></i></span></a>
<a class="btn btn-social-icon" title="JSFiddle" href="#"><span><i class="fa fa-jsfiddle"></i></span></a>
<a class="btn btn-social-icon" title="GitHub" href="#"><span><i class="fa fa-github"></i><span></a>
</div>
-->
<!--to delete
<li><a class="rssBtn smGlobalBtn" href="#" ></a></li>
<li><a class="linkedinBtn smGlobalBtn""></a></li>
-->
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<!--navbar ends-->
</body>
Include the break-point 768px in the media-query. Set a width for the icons parent element for margin: 0 auto to work.
#media (max-width: 768px) {
#mylinks ul.nav.navbar-nav.navbar-right.nav-pills {
width: 200px;
margin: 0 auto;
}
}
<!-- Placed at the end of the document so the pages load faster -->
< script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" > < /script>
<!-- Latest compiled and minified JavaScript -->
<script src="https:/ / maxcdn.bootstrapcdn.com / bootstrap / 3.3.5 / js / bootstrap.min.js "></script>
/*css plugin for jquery content*/
.contenthover {
padding: 20px 20px 10px 20px;
}
.contenthover,
.contenthover h3,
contenthover a {
color: #fff;
}
.contenthover h3,
.contenthover p {
margin: 0 0 10px 0;
line-height: 1.4em;
padding: 0;
}
.contenthover a.mybutton {
display: block;
float: left;
padding: 5px 10px;
background: #3c9632;
color: #fff;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
.contenthover a.mybutton:hover {
background: #34742d
}
/*website*/
body {
margin: 0px;
padding: 0px;
font-family: "Gotham SSm A", "Gotham SSm B", sans-serif;
font-weight: 300;
}
.navbar-text {
margin: 0px;
}
.navbar-text > i {
color: inherit;
text-decoration: none;
}
/****************modifying bootstrap***********************/
.navbar-default {
background-color: #fff;
margin-bottom: 0px;
}
#mylinks {
display: inline;
}
#centered li {
text-align: center;
}
.nav-pills {
padding-top: 5px;
margin-left: 0px;
}
#cont-socialmedia {
margin: 0px;
padding: 0px;
text-align: center;
}
#main_cont {
Padding-top: 15px;
Padding-bottom: 15px;
background-color: pink;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: blue;
/*Sets the text hover color on navbar*/
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: rgb(84, 5, 29);
/*BACKGROUND color for active*/
background-color: white;
}
.nav > li > a:hover,
.nav > li > a:focus {
text-decoration: none;
background-color: gray;
/*Change rollover cell color here*/
}
.navbar-default .navbar-nav > li > a {
color: rgb(84, 5, 29);
/*Change active text color here*/
}
#media (max-width: 768px) {
div#mylinks ul.nav.navbar-nav.navbar-right.nav-pills {
width: 200px;
margin: 0 auto;
}
}
<head>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Social icons -->
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<!--toggle-->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#mylinks" 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>
<!--brand-->
<a class="navbar-brand" href="#">MILY VIDAL</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-right" id="mylinks">
<ul class="nav navbar-nav" id="centered">
<li class="active">Portfolio<span class="sr-only">(current)</span>
</li>
<li>Contact
</li>
</ul>
<!--testing new way to put smedia-->
<ul class="nav navbar-nav navbar-right nav-pills">
<li>
<i class="fa fa-linkedin"></i>
</li>
<li>
<a href="http://twitter.com/" class="btn btn-social-icon btn-twitter">
<i class="fa fa-twitter"></i>
</a>
</li>
<li>
<a href="http://www.linkedin.com/in/" class="btn btn-social-icon btn-linkedin">
<i class="fa fa-linkedin"></i>
</a>
</li>
<li>
<a href="https://github.com/broadmarkio" class="btn btn-social-icon btn-github">
<i class="fa fa-github"></i>
</a>
</li>
</ul>
<!--
<div class="navbar-text">
<a class="btn btn-social-icon" title="LinkedIn" href="#"><span><i class="fa fa-linkedin"></i></span></a>
<a class="btn btn-social-icon" title="JSFiddle" href="#"><span><i class="fa fa-jsfiddle"></i></span></a>
<a class="btn btn-social-icon" title="GitHub" href="#"><span><i class="fa fa-github"></i><span></a>
</div>
-->
<!--to delete
<li><a class="rssBtn smGlobalBtn" href="#" ></a></li>
<li><a class="linkedinBtn smGlobalBtn""></a></li>
-->
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<!--navbar ends-->
</body>

Resources