As can be demonstrated in this fiddle, adding too many elements in a Bootstrap .nav
causes it to just add items vertically down. How would I go about limiting its height and making it horizontally scrollable?
To create a horizontal menu first take a div container and add links to it then add CSS property to customize the menu like background-color , text-decoration , padding , margin etc. To add horizontal scroll use overflow: auto and white-space: nowrap .
((JavascriptExecutor) driver). executeScript("arguments[0]. scrollIntoView(true);", element); This works for vertical scrolling but not for horizontal.
To enable horizontal scrolling, we can use the CSS property overflow-x. If we assign the value scroll to the overflow-x property of the container element, the browser will hide horizontally overflowing content and make it accessible via horizontal scrolling.
First you need to tell the ul
to not wrap and overflow into a scroll bar. Then the li
elements need to not be floated and display inline. This will do it:
ul.nav {
white-space: nowrap;
overflow-x: auto;
}
ul.nav li {
display: inline-block;
float: none;
}
Fiddle: http://jsfiddle.net/bmfcd3zt/8/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With