How to create a horizontal-scrolling nav in Bootstrap? - html

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?

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/

Try this:
.nav{flex-wrap:nowrap;overflow-x:auto}

First, here is a fiddle that I've found on a scrolling implementation of tabs.
Second, I don't think that it's a good UX to provide so many links in a tabbar. I recommend you to use dropdown menus or mega menu.

Related

How can I center a menu in a responsive website? (example)

I am having some grave difficulty to center a silly menu on the pages of my website. I know I can set the width of an outer div to a px value, but how can I make it so it centers for a responsive website? Here's the page:
http://103.4.17.225/~america/index.php/product-menu/vertical-garden/gro-wall-3
The menu is the benefits,gallery,etc.
Thanks guys , you're the bomb.
First, remove the float from the ul and set it to inline block;
.met_main_nav ul {
float: none;
display: inline-block;
}
Then use it's parent (the nav element) to center it, This will center any inline-block elements inside it (i.e the ul):
.met_main_nav {
text-align: center;
}
To center horizontal menus I often use a inline-block approach instead of a float one, try adding this to your stylesheet:
.sidemen .nav { text-align: center }
.sidemen ul li {
float: none; /* this will override your current line, just for testing */
display: inline-block;
}
If you add the code into your stylesheet, you can delete your current float rule, and just adding the display one.
The menu will be centered, no mater if you resize the browser, unless you do up to extreme narrow size, in which I'd recommend using media queries to adapt the menu rendering (reducing the margin or adapting styles to show in two lines perhaps).

How to prevent the sides of inline list element being cut off in HTML?

I have an issue with inline list elements.
The issue is that when I limit the width of my menu, which contains inline list elements, to put it onto multiple lines (for mobile devices) the right-side of elements is being cut off.
Here's a JSFiddle showing this: http://jsfiddle.net/vk2bK/7/
The menu in the orange with:
width: 210px;
background-color: #ffc20e;
In this JSFiddle the right-side of the 2nd list element is cut off. There's lots of space beside it in the div with the class 'menu', so it's not because of that. I assume it's because of some inline list property I'm unaware of.
How do I prevent the right-sides of inline list elements being cut off when the list expands onto a second line?
Simple CSS fix should do it.
You need to modify the li elements so they are inline block with a defined width:
.menu li {
display: inline-block;
width: 90px;
}
See it here: http://jsfiddle.net/vk2bK/21/
EDIT
I played around with it, see if this is what you want: http://jsfiddle.net/vk2bK/22/
ok i found a solution : JsFiddle
.menu a {
display: inline-block;
}
.menu a {
width:80px;
background-color: #7dc242;
line-height: 30px;
margin: 3px;
}
i removed the lists and made all elements inline-block u can edit their width and height if u need to.

Drop Down menu going up instead of down

Somehow my drop down menu isn't going down but is going to the top: http://fawky.de/fawky/powerbikes/index.html This is my full CSS, is something blocking it from going down?
Using top:50px; didn't work either.
http://pastebin.com/YqifT4JW
Thanks.
First of all remove position:absolute from .topmenu li. Then you should use visibility: hidden; instead of display: none; to hide the submenus. This way the submenu is hidden but the space for it is reserved (more info)
remove position:absolute from .topmenu li

css link not making all text a link?

I have dropdown menu and its made via a list and position absolute, however the dropdown links are very very very small area and do not cover the text completely.
How can I fix this?
Example http://outreviews.com/v%202/index.html (the dropdown menus)
Remove the padding from the sub menu's UL and LI and give the A element "display:block" This will make the A element take up the entire width of the menu.
You can fiddle with the padding to get it the way you want it.
If you add:
ul li a {
display: inline-block;
width: 100%;
height: 100%;
}
It should work okay, and since even IE allows display: inline-block; on natively in-line elements it should be relatively cross-browser friendly (certainly under a valid doctype).
It's worth remembering that padding on the parent li will also reduce the possible width of the child a element, and the display: inline on the same parent li is also likely to cause you a little trouble (since display: block; on the a would be so much simpler).
Edited to note that #Chris Bentley correctly noted the points in my final paragraph (above the hr) just prior to my answer.
make the following changes:
in #headermenu li change the padding:20px; to padding :0 20px;
add delete the top:55px; from #headermenu li ul
What you can do is make the li elements display:list-item and the a elements display:block. That's what's being done on the site you're linking to.

HTML CSS LI Wrapping

I have a vertical menu in my system which is basically made of HTML ul/li with CSS styling (see image below). However I don't want the li items which are wider than the menu to wrap, I would prefer them to overflow with a horizontal scroll bar at the bottom of the menu. How can I do this in CSS?
ul {
overflow: auto; // allow li's to overflow w/ scroll bar
// at the bottom of the menu
}
li {
white-space: nowrap; // stop the wrapping in the first place
}
Use white-space:nowrap. Like so:
li {
white-space:nowrap;
}
Here's some documentation.
You would also need to give the style the ul:
ul{
width:250px;
overflow:auto;
}