Topic: Center navbar buttons
Austin free asked 6 years ago
Austin free answered 5 years ago
That seems to make the background red on chrome/edge/safari/opera, blue on firefox, and green on IE.
Piotr Glejzer staff commented 5 years ago
Because this is not a standard and will not work for every user/browser.
https://developer.mozilla.org/en-US/docs/Web/CSS/@media/-ms-high-contrast
Piotr Glejzer staff answered 6 years ago
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none){ body{ background-color:#00FF00; } } @media screen and (-webkit-min-device-pixel-ratio:0){ body{ background-color:#FF0000; } } @-moz-document url-prefix() { body{ background-color:#0000FF; } }
Piotr Glejzer staff answered 6 years ago
<ul class="navbar-nav ml-auto nav-flex-icons d-md-flex align-items-center w-100">
But If you will do this it will be broke on other browers because on IE/edge is a bug with 'ml-auto'.
Best,
Piotr
Austin free answered 6 years ago
Piotr Glejzer staff commented 6 years ago
Microsoft Edge has fully support flexbox so it's probably some error did it, check your console. Have a nice day. Best Piotr.Austin free commented 6 years ago
I don't see any errors in the console. The navbar is also relatively large compared to how it appears in other browsers.Piotr Glejzer staff answered 6 years ago
It should looks like that.
<ul class="navbar-nav"> <li class="nav-item active "> <a class="nav-link waves-effect waves-light"href="http://partysprings.com">Home <span class="sr-only">(current)</span> </a> </li> <li class="nav-item "> <a class="nav-link waves-effect waves-light"href="http://partysprings.com/packages">DJ Packages </a> </li> <li class="nav-item "> <a class="nav-link waves-effect waves-light"href="http://partysprings.com/testimonials">Testimonials </a> </li> <liclass="nav-item "> <a class="nav-link waves-effect waves-light"href="http://partysprings.com/about">About </a> </li> <liclass="nav-item "> <a class="nav-link waves-effect waves-light"href="http://partysprings.com/contact">Contact </a> </li> </ul>
<ul class="navbar-nav ml-auto nav-flex-icons d-md-flex align-items-center"> <li class="nav-item"> <a class="nav-link waves-effect waves-light"href="https://twitter.com/partyspringsfl"> <i class="fa fa-twitter"></i> </a> </li> <liclass="nav-item"> <aclass="nav-link waves-effect waves-light"href="https://www.instagram.com/partyspringsfl"> <i class="fa fa-instagram"></i> </a> </li> <li class="nav-item"> <a class="nav-link waves-effect waves-light"href="https://www.facebook.com/PartySprings"> <iclass="fa fa-facebook-official"></i> </a> </li> <li class="nav-item"> <a class="nav-link waves-effect waves-light"href="https://soundcloud.com/partyspringsproductions"> <i class="fa fa-soundcloud"></i> </a> </li> <li class="nav-item"> <form class="form-inline my-2 my-lg-0 ml-auto waves-effect waves-light"> <a href="https://partysprings.com/contact"rel="nofollow" class=" waves-effect waves-light"><button class="btn btn-outline-white btn-sm my-2 my-sm-0 ml-3 waves-effect waves-light" type="button">Free Quote</button></a> </form> </li> </ul>
Austin free answered 6 years ago
Piotr Glejzer staff answered 6 years ago
<ul class="navbar-nav ml-auto nav-flex-icons d-md-flex align-items-center"> and <ul class="navbar-nav text-center"> to your ul list with links.It should fix links and flex icons. Do you want a center links in the display on large devices? Best, Piotr
Piotr Glejzer staff answered 6 years ago
Daimi Lamorú free answered 6 years ago
Piotr Glejzer staff answered 6 years ago
Austin free commented 6 years ago
Ok thanks. Is it possible to only enable d-flex on the desktop site?Piotr Glejzer staff commented 6 years ago
Yes, it is possible with d-md-flex or d-lg-flex. Everything is in our documentation ! Have a nice day.Austin free commented 6 years ago
I am trying to add nav-flex-icons and this breaks the centered navigation link buttons. I want the navbar icons to be on the left side of the nav bar and the link buttons to be centered. Also the last button/icon "Free Quote" is not positioned properly on mobile, its just a bit misaligned with the rest of the icons within the dropdown menu. Here's my site: https://partysprings.comPiotr Glejzer staff commented 6 years ago
Add something like that :Austin free answered 6 years ago
/* Your custom styles */ /* Navigation*/ .navbar { background-color: transparent; letter-spacing: 0.75px; } .nav-blue { background-color: #2b3b68; } .scrolling-navbar { -webkit-transition: background .5s ease-in-out, padding .5s ease-in-out; -moz-transition: background .5s ease-in-out, padding .5s ease-in-out; transition: background .5s ease-in-out, padding .5s ease-in-out; } .navbar .btn-group .dropdown-menu a:hover { color: #000 !important; } .navbar .btn-group .dropdown-menu a:active { color: #fff !important; } .top-nav-collapse { background-color: #177BA8; } .view { -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; }
Austin free answered 6 years ago
<!--Navbar--> <nav class="navbar navbar-expand-lg navbar-dark fixed-top scrolling-navbar"> <!-- Navbar brand --> <a class="navbar-brand" href="https://mysite.com" style="margin-right: 2.5rem; font-family: 'LibreBodoniRegular'; font-weight: normal; font-style: normal; letter-spacing: 0.5px;" ><img src="https://mysite.com/themes/zanor-zanor-mdb-loaded/assets/images/PS.svg" class="img-fluid mb-1" style="width: 100% 9; max-width: 12%; height: auto" alt="PS Logo"> PS</a> <!-- Collapse button --> <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> <!-- Collapsible content --> <div class="collapse navbar-collapse" id="navbarSupportedContent"> {% if staticMenu.menuItems %} {% set items = staticMenu.menuItems %} <!-- Links --> <ul class="navbar-nav mr-auto"> {% for item in items %} <li class="nav-item {% if this.page.title == item.title %} active {% endif %}"> <a class="nav-link" href="{{ item.url }}">{{ item.title }} {% if this.page.title == item.title %} <span class="sr-only">(current)</span> {% endif %}</a> </li> {% endfor %} {% endif %} </ul> <!-- Links --> <!-- Collapsible content --> </nav> <!--/.Navbar-->
Piotr Glejzer staff commented 6 years ago
Hi, can you check this? You need to remove mr-auto class and doing something like this.
<div class="collapse navbar-collapse d-flex justify-content-center" id="navbarSupportedContent">
<ul class="navbar-nav">
Austin free commented 6 years ago
That doesn't work with the <a class="navbar-brand" element as it is still too far to the right. If I remove the navbar-brand it is centered but I want it centered with the logo in the navbar at the left.Piotr Glejzer staff commented 6 years ago
You can use position absolute/relative to do this. Try my code. Style by #id is not a good option you can style but another class.
@media (min-width: 991px) {
#navbarSupportedContent {
position: relative;
left: -64px;
}
}
.navbar {
background-color: transparent;
position: absolute;
}
Austin free commented 6 years ago
left: -64px; does not translate the same over different display sizes right? There's no way to do this so it will show up in the exact center of the display on any monitor size?Austin free commented 6 years ago
Is it possible to only enable "d-flex justify-content-center" on the desktop site?FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
Piotr Glejzer staff commented 6 years ago
Hi, yes, I think it is possible. You can use our documentation about flexbox to style what do you want --> Flexbox But If you can show me your code I will try to help you. I recommend using the latest version of mdb because we change a few things in our code. Best, Piotr