Jordyn Jordyn - 2 years ago 78
HTML Question

Make a custom navigation scroll on mobile devices bootstrap

I made a custom navigation bar inside a div im using bootstrap. I want the overflow-x to be scroll on mobile devices. Issue is I want to keep the maximum width of the navigation bar on mobile device and scroll it.

I don’t want the li tags to be one below the other.

Ex: wrong way

Button 1

Button 2

Button 3

Button 4 so on

Correct way

Button 1 | Button 2 | Button 3 | Button 4 | so on and make it scroll on mobile devices


<div class="col-md-10">
<ul class="my-nav">
<li><a class="btn-nav tab-active" href="">Button 1</a></li>
<li><a class="btn-nav" href="">Button 2</a></li>
<li><a class="btn-nav" href="">Button 3</a></li>
<li><a class="btn-nav" href="">Button 4</a></li>
<li><a class="btn-nav" href="">Button 5</a></li>


.my-nav {
margin: 0;
padding: 0;
list-style: none;
.my-nav li {
float: left;
.my-nav li a, .my-nav li a:link, .my-nav li a:visited {
color: #000;
font-size: 15px;
.my-nav li a:hover {
border-bottom: 4px solid #CCC;
},, {
color: #27a020;
border-bottom: 4px solid #27a020;
.btn-nav {
display: block;
text-align: center;
padding:15px 25px;


Answer Source


To achieve this, you can add a media query for mobile width with an overflow-x: scroll; property for the parent of the nav bar :

@media (max-width: 640px){
  .parent { 
  .my-nav {
    height: 70px; 
    width: 600px; 

I volontary applied a fixed width to make the horizontal scroll works, but you can calculate it with a javascript script if you prefer.

Get informations about device width :

Live example

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download