Align Bootstrap 4 dropdown exactly to the width of the button - html

i had tried a lot not get a solution for this can u please help with this..actually im setting it by giving by minimum width to the dropdown menu but when in case of responsive and when menu item contains big words the menu items are expanding to out of the box.
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<nav id="navbar-two" class="navbar-nav navbar-toggleable-md mb-4">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="nav navbar-two-list mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">My Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">You & Peers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Family</a>
</li>
</ul>
<div class="mt-2 mt-md-0">
<ul class="nav">
<li class="nav-item">
<button class="btn btn-success dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Add Mutual Funds<sub><i class="fa fa-angle-down" aria-hidden="true"></i></sub></button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<a class="dropdown-item" href="#">Separated link</a>
</div>
</li>
</ul>
</div>
</div>
</nav>

I think you should put the button and dropdown together in a col and use btn-block so it always fill the column. Then you can resize the column responsively.
Demo: http://www.codeply.com/go/OE4tnyG1lt
<div class="container-fluid">
<div id="navbar-two">
<div class="row">
<div class="col-sm-8 col-md-9">
<ul class="nav navbar-two-list">
<li class="nav-item">
<a class="nav-link" href="#">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">My Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">You & Peers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Family</a>
</li>
</ul>
</div>
<div class="col-sm-4 col-md-3">
<ul class="nav">
<li class="col-12 px-0">
<button class="btn btn-success btn-block dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Add Mutual Funds<sub><i class="fa fa-angle-down" aria-hidden="true"></i></sub></button>
<div class="dropdown-menu w-100">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<a class="dropdown-item" href="#">Separated link</a>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
Demo: http://www.codeply.com/go/OE4tnyG1lt

You can use following code to set the width for both dropdown and button.just change the size of width
.dropdown-menu {
width: 100%;
}
.btn{
width: 100%;
}

You can use media queries. like,
#media only screen and (max-width: 768px) {
.dropdown-menu{
min-width: 400px;
}
}
#media only screen and (max-width: 480px) {
.dropdown-menu{
min-width: 320px;
}
}

You could clip the overflow when the text of the menu items gets too long:
.dropdown-item {
overflow:hidden;
white-space:nowrap;
text-overflow:ellipsis;
}
Note with the ellipsis property, overflowed content is indicated to the user with dots instead of just hard clipping the content

Related

NAVBAR responsive from fixed to not fixed

I am making a responsive navigation bar and I encountered a problem. Fixed navbar is correct and works fine. It changes transparency when scrolled, but I don't want the hamburger menu (when the device is small) to be fixed in place. How can I change from fix? What attribute should I changed? I am using bootstrap for this. Thank you!
$(function() {
$(window).on('scroll', function() {
if ($(window).scrollTop() > 10) {
$('.navbar').addClass('active');
} else {
$('.navbar').removeClass('active');
}
});
});
function scrollValue() {
var navbar = document.getElementById('navbar');
var scroll = window.scrollY;
if (scroll < 200) {
navbar.classList.remove('BgColour');
} else {
navbar.classList.add('BgColour');
}
}
window.addEventListener('scroll', scrollValue);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header class="header">
<div id="navbar" class="navbar">
<nav class="navbar navbar-expand-lg fixed-top bg">
<img src="images/logo.png" class="img-fluid" id="weblogo" onclick="submitToPage1();" alt="Image Not Found">
VITALY TEA
<div class="container-fluid">
<button type="button " data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler navbar-toggler-right navbar-static-top container-hamburger "><i class="fa fa-bars"></i></button>
<div id="navbarSupportedContent" class="collapse navbar-collapse">
<ul class="navbar-nav ml-auto ">
<li class="nav-item dropdown" id="navbtn">
<a class="nav-link dropdown-toggle" href="#Services" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" onclick="submitToPage2();">
Services
<span class="sr-only">(current)</span></a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink" id="subnav">
<a class="dropdown-item" href="#">Digital Printing</a>
<a class="dropdown-item" href="#">Binding</a>
<a class="dropdown-item" href="#">Laminating</a>
<a class="dropdown-item" href="#">Cutting</a>
</div>
</li>
<li class="nav-item dropdown" id="navbtn">
<a class="nav-link dropdown-toggle" href="#Menu" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" onclick="submitToPage3();"> Menu
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink" id="subnav2">
<a class="dropdown-item" href="#">Warm Drinks</a>
<a class="dropdown-item" href="#">Cold Drinks</a>
<a class="dropdown-item" href="#">Sandwiches</a>
</div>
</li>
<li class="nav-item"><a class="nav-link" id="navbtn2" href="#Orderr" onclick="submitToPage4();">
Order </a></li>
<li class="nav-item"><a class="nav-link" id="navbtn2" href="#About" onclick="submitToPage5();">
About </a></li>
<li class="nav-item"><a class="nav-link" id="navbtn2" href="#Contact" onclick="submitToPage6();">
Contact </a></li>
<li class="nav-item"><a class="nav-link" id="navbtn2" href="#Link" onclick="submitToPage7();"> Link
</a> </li>
</ul>
</div>
</div>
</nav>
</div>
</header>

How to insert a logo in a sidebar menu

So I have been trying to create a lateral menu that has a logo right on top of it as well as a traditional navigation menu next to it. But I seem to have ran into a problems where I cannot put my logo inside the lateral menu and to align it. Here is the code I have so far that I am trying to use. My final goal is to have it like this mockup that of a page I have made, any help will be most welcome https://i.stack.imgur.com/wwcXT.png
<header>
<nav class="my-nav navbar navbar-light navbar-expand-lg">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-
target="#navbarsExample08" aria-controls="navbarsExample08" aria-expanded="false" aria-
label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-md-center" id="navbarsExample08">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown08" data-toggle="dropdown" aria-
haspopup="true" aria-expanded="false">ACTIVITES</a>
<div class="dropdown-menu" aria-labelledby="dropdown08">
<a class="dropdown-item" href="#">Rafting</a>
<a class="dropdown-item" href="#">Canooing</a>
<a class="dropdown-item" href="#">Parachute</a>
<a class="dropdown-item" href="#">Soufflerie</a>
<a class="dropdown-item" href="#">Saut elastique</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">OFFRES</a>
<li class="nav-item">
<a class="nav-link" href="#">EVENEMENTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">A PROPOS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ESPACE HANDICAP</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</li>
</ul>
</div>
</nav>
</div>
<nav class="navbar-lateral">
<ul>
<li class="logo">
<a href="" class="nav-link">
<img src="./img/so.png" alt="">
</a>
</li>
</ul>
</nav>
CSS for lateral bar
.navbar-lateral {
width: 5rem;
height: 100vh;
position: fixed;
background: white;
}
You can use Bootstrap built-in nav for the horizontal like you did and add a custom navbar to the lateral side with the logo inside it. Something like this:
HTML
<header>
<nav class="my-nav navbar navbar-light navbar-expand-lg">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-
target="#navbarsExample08" aria-controls="navbarsExample08" aria-expanded="false" aria-
label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-md-center" id="navbarsExample08">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown08" data-toggle="dropdown" aria-
haspopup="true" aria-expanded="false">ACTIVITES</a>
<div class="dropdown-menu" aria-labelledby="dropdown08">
<a class="dropdown-item" href="#">Rafting</a>
<a class="dropdown-item" href="#">Canooing</a>
<a class="dropdown-item" href="#">Parachute</a>
<a class="dropdown-item" href="#">Soufflerie</a>
<a class="dropdown-item" href="#">Saut elastique</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">OFFRES</a>
<li class="nav-item">
<a class="nav-link" href="#">EVENEMENTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">A PROPOS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ESPACE HANDICAP</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</li>
</ul>
</div>
</nav>
</div>
<div class="lateral-nav">
<img src="https://tkruger4.files.wordpress.com/2010/11/logo-2_rgb.jpg" alt="">
item
item
item
</div>
CSS
.lateral-nav {
position:absolute;top:0;left:0;width:100px;background:white;height:300px;display:flex;flex-direction:column;justify-content:flex-start;align-items:center;
}
img {
width:60px;height:60px;margin-top:10px;
}
.lateral-nav a {
writing-mode:vertical-lr;text-orientation:mixed;margin:10px 0;}
.navbar {
margin-top:10px;
}

bootstrap 4 making dropdown scrollable

I have a problem with my drop down menu on smaller devices. i cannot make it scroll able when i tried the solution here (that is overflow:auto/ overflow-y:scroll) it's not working even if i use !important. What i'm able to scroll was my main page even if the drop down is open.
<nav class="navbar navbar-toggleable-sm ">
<button class="navbar-toggler navbar-toggler-right main-navbar-toggler" type="button" data-toggle="collapse" data-target="#main-nav-collapse" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
<span class="fa fa-bars"></span>
</button>
<a class="navbar-brand animation" data-animation ="fadeInLeft" href="#"><img src="/093017/img/logo-tmi.png" alt="logo"/></a>
<div class="collapse navbar-collapse" id = "main-nav-collapse" >
<ul class="nav navbar-nav navbar-main mr-auto mt-2 mt-md-0 animation" data-animation = "fadeInRight">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Vehicles</a>
<div class="dropdown-menu default-menu main-menu sm-main-menu animation" data-animation = "fadeIn">
<!-- Nav tabs -->
<div class="sm-main-nav" >
<a class="dropdown-item" href="#">Cars</a><hr>
<a class="dropdown-item" href="#">Vans & Pickup</a><hr>
<a class="dropdown-item" href="#">SUVs & Crossover</a><hr>
<a class="dropdown-item" href="#">MPVs</a><hr>
<a class="dropdown-item" href="#">Hybrid</a><hr>
<a class="dropdown-item" href="#">Performance</a>
</div>
</div>
</li>
<li class="nav-item">
<a class="nav-link " href="#">Owners</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Shop</a>
</li>
<li class="nav-item">
<a class="nav-link " href="#">Promotions</a>
</li>
</ul>
</div>
just you can use #media in your css
#media (max-width: 500px) {
.dropdown-menu{
height:200px;
overflow-y:auto;
}
}
Use max-height instead of height:
.dropdown-menu {
max-height: 200px;
overflow-y: auto;
}
What I can suggest is in place of hard coding height in pixels you can take the advantage of the view port height like adding this style to your dropdown-menu item or add at the class level
Inline
style="overflow-y:auto; max-height:80vh"
For every dropdown
.dropdown-menu {
overflow-y:auto;
max-height:80vh
}
You can use a custom class for scroll bar for dropdown list.
<div class="sm-main-nav customClassForDropDown" >
<a class="dropdown-item" href="#">Cars</a><hr>
<a class="dropdown-item" href="#">Vans & Pickup</a><hr>
<a class="dropdown-item" href="#">SUVs & Crossover</a><hr>
<a class="dropdown-item" href="#">MPVs</a><hr>
<a class="dropdown-item" href="#">Hybrid</a><hr>
<a class="dropdown-item" href="#">Performance</a>
</div>
This is the custom css class.
.customClassForDropDown
{
height: 100px;
overflow-y: auto;
}
check this JSFIDDLE

swap divs left right on mobile view

I want to have the header bar with three elements like below
But in mobile view i want menu(toggle-icon) to go left and logo should come middle. I tried push and pull. but that doesn't work for me. Is there anyway i can achieve this?
Here is my code. FYI, I did not add any separate media query yet. Just using the bootstrap classes.
<div class="row d-flex flex-nowrap" style="background-color: #2B3536;">
<div class="col-lg-1 col-md-1 col-sm-2 col-2 align-self-center"><img src="https://dummyimage.com/127x50/2b3536/fff"></div>
<div class="col-lg-8 col-md-9 col-sm-8 col-8 order-sm-first">
<nav class="navbar navbar-fixed-top navbar-toggleable-sm navbar-expand-sm">
<div class="container d-flex flex-row flex-md-nowrap flex-wrap">
<a href="#" class="hidden-md-up mr-3" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false">
<i class="fa fa-bars fa-lg text-white"></i>
</a>
<!--<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">
<ul class="navbar-nav header-nav">
<li class="nav-item">
<a class="nav-link" href="#">Menu 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Menu 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Menu 3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Menu 4</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact Us</a>
</li>
<!--<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>-->
</ul>
</div>
</div>
</nav>
</div>
<div class="col-lg-3 col-md-2 col-sm-2 col-2 align-self-center">
<div class="input-group">
<input class="form-control hidden-md-down"
placeholder="I'm looking for">
<div class="input-group-addon top-search-addon"><i class="fa fa-search fa-search-white"></i></div>
</div>
</div>
</div>
you should add media query to style css file
.navbar-brand{
padding-top:8px;
}
.navbar-brand img{
height:35px;
width:35px
}
#media (max-width:767px) {
.navbar-brand{
position: absolute;
left: 40%;
}
}
.navbar-toggle {
float: left;
}
you can view alive demo menu design

Bootstrap 4 Split Navbar - Responsive Dropdown Below not Beside

I have a navbar with a split dropdown. The particular portion of the HTML I'm interested in is this:
<li class="nav-item">
<div class="btn-group">
Blog
<a class="nav-link dropdown-toggle dropdown-toggle-split" id="dropdownMenuLink_blog" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown for Blog Links</span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink_blog">
<div class="dropdown-header">Categories | Blog Main</div>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=20" target="_blank"><small><em>Articles for Everyone</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=8" target="_blank"><small><em>Access to Justice Commentary</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=5" target="_blank"><small><em>Law Commentary</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=6" target="_blank"><small><em>Legal Futurism</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=4" target="_blank"><small><em>Resources for Lawyers</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=36" target="_blank"><small><em>Technology</em></small></a>
</div>
</div>
</li>
And the entire navbar looks like this:
<nav class="navbar navbar-toggleable-sm fixed-top">
<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">
<i class="fa fa-bars fa-lg" aria-hidden="true"></i>
</button>
<a class="navbar-brand" href="#home">Brandon D. Hastings<small class="hidden-md-down"> BBA(Dist.), JD</small></a>
<div class="navbar-collapse collapse" id="navbarNavDropdown">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#about">About<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#law">Law</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#technology">Technology</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#media">Media</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink_more" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">More</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink_more">
<a class="dropdown-item" href="#miscinfo">More About Me</a>
<div class="dropdown-divider"></div>
<div class="dropdown-header"><em>New Tab / Window</em></div>
<a class="dropdown-item" href="http://(bitly not allowed)/BHastings_CV" target="_blank">Curriculum Vitae</a>
<a class="dropdown-item" href="http://bhastings.com/blog/category/resources-for-lawyers/" target="_blank">Resources for Lawyers</a>
</div>
</li>
<li class="nav-item">
<div class="btn-group">
Blog
<a class="nav-link dropdown-toggle dropdown-toggle-split" id="dropdownMenuLink_blog" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown for Blog Links</span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink_blog">
<div class="dropdown-header">Categories | Blog Main</div>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=20" target="_blank"><small><em>Articles for Everyone</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=8" target="_blank"><small><em>Access to Justice Commentary</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=5" target="_blank"><small><em>Law Commentary</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=6" target="_blank"><small><em>Legal Futurism</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=4" target="_blank"><small><em>Resources for Lawyers</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=36" target="_blank"><small><em>Technology</em></small></a>
</div>
</div>
</li>
<li class="nav-item btn btn-danger btn-sm">
<a class="nav-link text-white url-firm" href="http://www.quaylawcentre.com/Lawyer-Profiles/Brandon-Hastings-B-b-a-dist-j-d.shtml" target="_blank">Get in Touch<span class="sr-only"></span></a>
</li>
</ul>
</div>
</nav>
The result is something like this in small screens:
Having a split link in a navbar is a bit hacky to begin with, but notwithstanding that, I'm wondering if anyone knows a way to get the dropdown to pop back "in line" so that it looks more like the "More" dropdown:
?
Thanks in advance! :)
Just add container class in the btn-group div.
The misalignment is because of the btn-group class is defined as flex item. Try adding container class, it may solve the issue.
<div class="container p-0 btn-group">
Blog
<a class="nav-link dropdown-toggle dropdown-toggle-split" id="dropdownMenuLink_blog" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown for Blog Links</span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink_blog">
<div class="dropdown-header">Categories | Blog Main</div>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=20" target="_blank"><small><em>Articles for Everyone</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=8" target="_blank"><small><em>Access to Justice Commentary</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=5" target="_blank"><small><em>Law Commentary</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=6" target="_blank"><small><em>Legal Futurism</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=4" target="_blank"><small><em>Resources for Lawyers</em></small></a>
<a class="dropdown-item" href="http://bhastings.com/blog?cat=36" target="_blank"><small><em>Technology</em></small></a>
</div>
</div>
The HTML below works when you expand a collapsed navbar!
Bootstrap: 5.0.0-beta2
<li class="nav-item col-6 col-md-auto">
<!-- NOTE: d-table on the group and nav-link d-inline for the inner <a> tags is a must for split button to work properly when collapsed/expanded -->
<div class="btn-group d-table nav-link p-2">
<a class="nav-link d-inline">Dropdown link</a>
<a class="nav-link d-inline" role="button" data-bs-toggle="dropdown">
<i class="far fa-caret-square-down"></i>
</a>
<ul class="dropdown-menu ">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
</li>
I guess this isn't a very clean answer but I added some margin and it does the job. But can't wait to see a better solution.
#media (max-width: 992px) {
.dropdown-menu {
margin:35px 0 0 -150px;
}
}