Do you want to add this user to your connections?
Connect with professionalInvite trusted professional to work on your projects
How to start working with us.
Geolance is a marketplace for remote freelancers who are looking for freelance work from clients around the world.
Create an account.
Simply sign up on our website and get started finding the perfect project or posting your own request!
Fill in the forms with information about you.
Let us know what type of professional you're looking for, your budget, deadline, and any other requirements you may have!
Choose a professional or post your own request.
Browse through our online directory of professionals and find someone who matches your needs perfectly, or post your own request if you don't see anything that fits!
In the above example of a bootstrap navbar, we have used a sample of what might be some website's navigation menus. As you can see on the top corner, an image is there representing a logo or a brand name and then taking up all of its parent element widths. This looks good but will give an issue if your image logo is small and doesn't take up all of its parent element widths, Consequently leaving behind space for other elements on your webpage or web application to occupy your browser window.
Instructions for creating a bootstrap navigation bar with a logo that is larger than the default height (50px) and width (100px) of a bootstrap navbar Default logo size
With time, I have seen that it is highly required to have an image logo bigger than the default size. And if you want to keep your navbar height and width fixed, then it would be great if the image logo can occupy all or most of its parent element width. This makes sure that there are no empty spaces left behind for other elements to make space.
Having an image logo that takes up all of its parent element widths can be a great way to show off your brand, but what do you do if your logo is small?
Geolance has the perfect solution for you! Our responsive navbar will make sure that no matter how big or small your logo is, it will always look good.
With Geolance, you'll have a website or web application that looks amazing and functions perfectly on any device. You won't have to worry about any space being left behind by your image logo anymore.
Let's understand what each line means in detail:
Line 3-4: Now importing fewer variables files in your HTML document (You can also find this file on GitHub)
Line 5: Changing bootstrap.min.css to bootstrap 4's main CSS file
Line 9: Declaring a custom class named .navbar-custom for your navbar
Line 10-12: Now apply our desired style properties to the HTML element which is wrapping around the entire navbar
Here I have used the following CSS styling:
Sr. No. Style Properties Value 1 .logo text-align center 2 .logo img max-height 100px 3 .logo img max-width 130px 4 .wrapper height 70px 5 .dropdown-divider line-height 30px 6 gutter 10px
These CSS styling will help you in creating your custom navbar. And if you are wondering why did I use the 70px height property for the wrapper element, then let me tell you that this value was arrived at after some trial and error. Just keep on playing with values till you find one suitable for your web application or webpage design.
Democracy in action
Now you need to decide that either your navbar will have a logo or a button or both. Following is the code that I am using in my latest web application, which has only a button and no logo:
Code for Bootstrap 4 Navigation Bar with Button only
On lines 3-4 of the above code, we have imported fewer variables files from GitHub and on lines, 10-12, applied properties to HTML element wrapping around the entire navbar. And if you are wondering what div id="bootstrapDemoBtn" is doing there, then it's simply being used as a container for button styling purposes. You can define its class by yourself just like I did. If you liked this article then do me a favour by sharing it on social media.
Bootstrap 4 Navbar with Text and Logo
Please note that there is nothing new about this feature as such. It's just a combination of different bootstrap features to achieve the desired result. For example, we have used the .navbar-custom class which was introduced in the bootstrap v4 alpha version (Another bootstrap 4 hidden gem). And then we also used some basic styling like height and width for wrapper element and logo text alignment etc. You can modify it accordingly or if you think that I am missing anything, do let me know via the comments section below.
Navigation menus with buttons, logos, or brand text can be easily achieved in Bootstrap 4 using the navbar-custom class from the bootstrap alpha version. This is a very powerful and yet unknown feature of bootstrap v4. And I have been able to use it in my latest web app that I am building at present. Here's how you can do it:
Instructions for creating a bootstrap navigation bar with a logo that is larger than the default height (50px) and width (100px) of a bootstrap navbar Default logo size With time, I have seen that it is highly required to have an image logo bigger than the default size. And if you want to keep your navbar height and width fixed, then the only way to do is to have your logo as a background image. And, if you are using bootstrap from CDN, then it's frustrating because you won't be able to modify any CSS or JS file on the Bootstrap CDN domain. It also prevents you from editing the fewer variables file and customizing things as per your need.
Now, I have extracted a minute portion of my HTML markup which is having navbar-custom class applied to HTML element which is wrapped around the entire navbar:
Code for bootstrap v4 navigation bar with text and button Note that height value (70px) for wrapper div has been obtained via trial and error method. I just kept on changing values till I found one suitable for my web application. And in the above code, you might have noticed that I have used two extra classes called .logo and .dropdown-divider. This CSS styling has been applied to the HTML element which is being used as a logo in the above navbar:
Logo with dropdown divider If you want a simple logo without any background colors or border lines, then just copy the code given below. You can apply it anywhere where you want your logo to appear: <div class="d-inline-block text-uppercase align-center justify-content-between mt0"> <div class="container"> <div class="row mb1"> <div class="col lg:mt4"> <div class="logo">LOGO</div> </div> <!-- end .col --> <hr class="my-4 sm12" /> <!-- dropdown divider --> <ul class="nav d-none d-md-inline ml1 mr1"> <li><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="hidden-xs text-uppercase font-weight-bold">DROPDOWN</span></a></li> <li><a href="#" id="bootstrapDemoBtn"><i class="fa fa-book"></i> Button Text Here</a></li> </ul> <!-- end .nav --> <hr class="mt0" /> <!-- end .row --> </div> <!-- end .container --> </div> <!-- end .d-inline-block -->
Note: The above code has been borrowed from Bootstrap's official documentation. And I have just removed extra classes/ids used by bootstrap for alignment purposes so that it can be easily plugged into your existing navbar. For the demo, I am using a flatly colored background image for a logo, but you can use any image you like or simply go with a text logo instead of an image one. Repositioning the dropdown submenu It is also possible to move submenu items above or below to primary menu items instead of placing them right next to primary links. You can do this by using my-2 or my-1 classes in the .navbar-custom class. You can modify it according to your requirements:
Code for bootstrap v4 navigation bar with dropdown divider Note that for the above navbar I have used my-3 class instead of default my-xs for button styling.
Of dropdown divider and setting button alignment On the flip side, you might have noticed that I haven't set any align value for the my-3 class. And this is possible because, by default, bootstrap v4 sets the text alignment of button links to the center unless it's overridden while defining custom buttons. So, just add the .btn-custom class to it and go ahead:
Code for bootstrap v4 navigation bar with dropdown divider and custom button Note: To make things more customizable, I am enclosing all related HTML code inside a separate div having id=" navbar" instead of using plain HTML element. That's why I am adding an inline style (style=" display: inline") above code which is required to override the bootstrap v4 default display style of the navbar HTML element.
Modifying dropdown divider color The default color of the dropdown divider is f7f7f7(light grey). You can change it by modifying mr1 class present in the .navbar-custom class. If you don't want to use any color, then simply remove that class from your existing code or you can toggle it with d-none class for complete removal of divider:
Code for bootstrap v4 navigation bar with no dropdown divider Note: I have removed height value (70px)from wrapper div as well as logo HTML markup because they are not required anymore if you're not using any kind of custom content on the navbar.
Coloring primary menu items The .navbar-custom class is required if you're using any custom style to override bootstrap v4 styling. If not, then just remove it and go with the regular navbar as shown below:
Regular bootstrap v4 navigation bar Note: While the above regular navbar uses default color values for all primary links/buttons, there are two more classes(sm1 & sm2) available in bootstrap v4 which can be used to quickly change their color values by 50% each. For example, use ml1 class instead of mr1 if you want dark grey button/links with light grey border lines.
Navigation bars using typography text I have already added a small heading text inside the primary menu for demo purposes. You can easily remove it by adding the following code to your existing HTML markup:
Code for bootstrap v4 navigation bar with logo/image instead of text Logo/Brand name is an important part of every website, so if you don't want to go with plain text or any image then simply upload a nice looking graphic on top of your website's name and use that as a logo in place of heading text shown above. I have also used a small size H1 tag instead of using a p tag so that it matches with the default font size value set in the .navbar-custom class(font-size: 18px). But obviously, you can even change this font size without modifying navbar CSS.
Bootstrap v4 navbar with footer nav links Note: I have used sm2 color value for link color in the above code so you might want to change it accordingly if you're using any other class instead of default sm1. The .nav-tabs class is required to trigger the dropdown submenu on the navbar. You can easily remove the footer menu by removing that nav-tabs class from your existing code or just simply replace nav-tabs with nav-pills as shown below:
Code for bootstrap v4 navigation bar without footer divider As you can see .nav-pills is also required when modifying primary links/buttons styling using my classes like mr1, ml1, etc.
Displaying content inside your navbar Navigation links/Buttons are not the only thing that you can add or modify in bootstrap v4 navigation bars. It's a wrapper div and it has got some space that you might want to use for putting custom content. For example, here I am displaying my heading text on the website name using .nav-header class:
Code for bootstrap 4 navigation bar with header You can easily remove this text from the top by removing the following code from your existing markup:
Adding group of buttons inside dropdown menu To add multiple buttons directly at navigation bar level, simply put them within a new div having class .btn-group. For example, if you have two or more social links or buttons to manage your account, you must group them inside .btn-group class like below:
Add multiple links/buttons in bootstrap v4 navigation bar Note: .navbar-btn is required for adding custom btn styles. If it's not present, simply remove that line of code and go with regular navbar styling for your website.
You can also create groups within the dropdown menu using the same technique shown above. Just add another button group along with dropdown list items to access the desired ones easily. For example, I have created one more div to display social media icons (LinkedIn + Facebook) in addition to normal buttons available in the top navbar group:
Adding two groups of buttons in the bootstrap v4 navigation bar Note: It's not necessary to add dropdown list items for both groups. You can simply hide all of them by creating a div with class .dropdown-list & then remove li*:only-child from .navbar-nav to hide dropdowns.
Adding labels along with buttons In bootstrap v4, you can also add labels along with your custom style buttons/links using custom btn classes within a new div having class `btn-group`. For example, I have created one more button group inside the navbar and added the label "Note:" before it:
Add buttons/labels in bootstrap 4 navigation bar Simply remove the note label from your existing code or replace the note label with another label text.
Bootstrap 4 navigation bar with dropdown menu You can also create a complete bootstrap v4 navigation-based sidebar using the following markup:
Navigation sidebars are now easy to implement in bootstrap 4! Note: I have used the label "Note:" before my first button group for this example because there is nothing much you can do with it once you're on your website dashboard and clicking on the Dashboard link takes you directly to the dashboard page. But if you're using some other layout structure like providing social media buttons or related articles or something else then obviously, that label or note will not be required anymore. Hence just go for placing notes/labels wherever possible just to keep your code cleaner and professional-looking as well.
Bootstrap 4 navigation menu with logo image I have also added an image in my left sidebar to display it along with the label. Here is the code for that: You can easily include your custom logo or any other small images within Bootstrap Navigation bars by simply wrapping them in a new div having class `navbar-header`.
bootstrap 4 navigation bar Simply put your logo image or any other content you want to display inside this wrapper div and the rest will be done by Bootstrap.
You can also use a list of links within the navbar header instead of putting a single image, for example:
Adding multiple buttons/links in bootstraps v4 header group Another thing I noticed is that there is some space at the top right which you might want to utilize for other purposes as well. Here's how it looks like with a tiny bit of padding added: You can easily remove that padding from your existing code or simply add more CSS classes but make sure those work fine on smaller screens as well because those classes should only be when extra spacing is required along with your logo image and header group.
Supported content within navbar header
You can also use your image or any other content inside the navbar header. But make sure it should be responsive, otherwise, you'll end up with an ugly-looking navbar on smaller screens after all.
Bootstrap 4 collapsible navigation bar This is how I have created a bootstrap v4 collapsible navbar by including navbars within navbars! I have used the same markup to create both the menu items and sub-menus/navbars inside dropdown but this time just wrapped it all in another class .navbar-collapse which contains two default divs - `.collapse` & `.carousel`.
Bootstrap code for collapsible navbars Here is some of the things to keep in mind before creating your bootstrap collapsible navbars: 1. Although it's ok to wrap anything inside `.collapse` in terms of accessibility, it is recommended that you use only one `div`. 2. On smaller screens, you should probably remove the inner-most .navbar & .btn-group divs since they don't serve you any purpose there and just add more padding to provide some space for labels/text right below them due to line length issues on small screen devices. 3. You can get rid of extra spacing at the top or bottom by adding classes - `pull-*`, `push-*` whatever floats your boat whenever required depending upon where extra spacing is required to make things look great! Here's what that collapsible navbar looks like on smaller screens:
Creating Bootstrap v4 pull/push collapse bars Another thing I noticed was at their homepage (Bootstrap 4 documentation), they are using another type of collapsible navbars where the brand logo is pushed to the right side along with labels. You can push any content within .collapse by adding p-* or h-* classes before collapsing it. It works the same as hn-*, pr-*, so simply replace those letters accordingly and you're done! Here's what that markup looks like:
Bootstrap 4 collapse navbar - collapsed This is how it will look when collapsed. As you can see there is no space at the bottom but just above the .navbar, so it will be removed on smaller screens with `.pull-sm-*`. Here's the compiled bootstrap code for that collapse navbar:
Bootstrap 4 collapse navbars in action With this article, I am again wrapping up with my series of Bootstrap v4 tutorials! Just in case you are interested in getting more updates on upcoming versions of Bootstrap, make sure to bookmark this blog or simply subscribe to our free email newsletter. There are many things left that are yet to be covered by me concerning Bootstrap v4 but I guess this is good enough for time being.
Color schemes in Bootstrap v4
You can use color schemes on their documentation page to get an idea about what the colors look like.
Bootstrap 4 - Customizing your navbar So, this is an awesome example which I found on their documentation regarding a custom navbar design with a few lines of code:
Customizing Bootstrap's Default Navbar In the above example, they have created a simple navigation bar and then customized it by adding extra links inside .nav-tabs along with buttons right below it using the `.nav-item` class which contains overflow if you want to add any more content later on! Here's what that navigation bar looks like:
Here are some of the things to keep in mind before creating your custom navbars: 1. The classes - `.navbar-brand`, `.nav-pills` and `.nav-tabs` all should be direct children of .navbar class. 2. Keep in mind that you can create any number of `li` elements inside the .nav-tabs but they must not contain more than one link with different href attributes or else it will end up creating sibling tabs instead of working as a single set of tabs!
Bootstrap 4 Navbar Demo I have created another custom navbar design for this demo which uses the same markup from the above example, so make sure you check out both examples on their documentation page to get an idea about how it works!
How it works
The collapse navbar is a super neat component of Bootstrap 4 which can be accessed by clicking on the hamburger menu button at the top right corner of the navbar. It automatically collapses into a single line and then stretches out if you click on it again, thus creating plenty of space for your content.
How to apply custom styles? The components in Bootstrap 4 are built using Sass so you need to create variables first before applying any custom style. For example, let's say I want to change the color of my navbar links/texts when it collapsed, I can create the following variable for that:
Sass $nav-link--default-color: #0099ff;
How to align contents inside the navbar? You can either use negative margins or just wrap everything inside a div and apply the styles. Here's what that looks like:
Bootstrap 4 Navbar with static footer This is something I wanted to know for quite some time now, so here it goes. If you want your navbars to have limited height in Bootstrap v4, all you need to do is add the following snippet of CSS inside `bootstrap-variables.scss` file (or wherever your variables are defined).
Geolance is an on-demand staffing platform
We're a new kind of staffing platform that simplifies the process for professionals to find work. No more tedious job boards, we've done all the hard work for you.
Geolance is a search engine that combines the power of machine learning with human input to make finding information easier.