Take my site for example: http://davidwalsh.name. Building a single drop-down section 3 If you want to make this navigational unordered list horizontal, you have basically two options: Now let’s make a couple common decisions about how we want to display this menu: Now we are in trouble. Thanks for the time to read this. Here you can see anunformatted list with some sample content: first item 1. definition for first item in list second item 1. definition for second item in list extending across more than one line third item 1. definition for third item in list There are two options for adding some formatting. For one, it’s nice to the wrap the menu in something so you have some positioning possibilities. but that dosnt seem to crack it either. An element with position: sticky will behave like a relatively-positioned element until it reaches a specified point and then starts behaving like a statically-positioned element. }, .navexample01 a { display: inline; This small amount of CSS will make any area have horizontal scrolling. For starters, IE probably won’t obey that min-width so you may need to do something else there. On your site it looks like you wrapped it inside a DIV. Download my free CSS Grid cheat sheet, and also get two quality interactive Flexbox courses for free! I cannot post my results as I am under a strict deadline for this particular project! Then we are going to style the list with CSS (Cascading Style Sheets) into the form of a horizontal navigation menu like in Picture 1 . In this article. Some CSS flex properties are used only on … @LukeR: Yeah I can see the menu isn’t centered in IE6. If you’d like me to post my results, I can most certainly do so upon request! how would you do it if you were using display:block and not display:inline. background-image: url(images/example.jpg); Weird. You can take out all the white space in the HTML between the s. your css code worked for the drop down menus I wanted to center but when I added images to be at the top of the page the menu got put back on the left again, what did I do wrong? @david walsh: I had a look at your code and have to say it doesn´t look very good in terms of website accessibility. } A problem with using display: inline on your list items is that, since they’re inline elements, the white space in-between the elements will translate to a space the width of a regular space of the font. Ugh, I just realized I used you’re instead of your. I think perhaps stefan is saying that with CSS turned off (screen-reader-style), menus that use the unordered list technique revert to a regular looking list (with bullets) which is a pretty nice way to degrade. any help would be greatly appreciated. float: left; )… yet that alters the behaviour drastically and/or puts a gap infront of each list item. background-repeat: no-repeat; Now let’s get started building that navigation bar! The Flexbox Layout (Flexible Box) module (a W3C Candidate Recommendation as of October 2017) aims at providing a more efficient way to lay out, align and distribute space among items in a container, even when their size is unknown and/or dynamic (thus the word “flex”).. If you want to make this navigational unordered list horizontal, you have basically two options: Make the list items inline instead of the default block. That’s it. Let’s specifically tell the browser to only scroll the card section. There’s a new value in town for the CSS position property: sticky.It allows us to make elements stick when the scroll reaches a certain point. The best way to do it is, letting a part of the scrollable content peek out. Obviously there’s a bit more styling than that, but that seems to do the trick of lining it up with the middle of the page. Using lists for navigation makes for me a lot of sense when you consider this point. min-width: 50px; This post is a follow up to a different method for horizontal scrolling navigation which used inline-block. Until then, I’ll continue my crusade against navigation lists. I’m having some trouble implementing your centered li. Building the navigation bar: Using flexbox to build a simple navigation bar for our imaginary e-commerce platform 2. display: inline; max-width:880px; Set the flex … Flex is a set of rules for automatically stretching multiple columns and rows of content across parent container. It’s just off to the left though, doesn’t look too awful. Line 3 ensures that the width of each card is never less than 200px , everything else is pretty simple. :D. Cheers! You make me really easy. IE doesn’t like it when it’s floated. To be honest I’m not exactly sure why, but applying .ul {margin: 0 auto;} just doesn’t work here. width: 50px; }, This seems a very complicated way of going about things. list-style: none; text-align:center; /* This is the tweak i made */, } }. background-position: left top; With this code I attached the following CSS (generalized): #navcontainer ul { .hortable { background-position: left top; If you are familiar with Stu Nicholls from CSSPlay, he uses this all the time on his awesome horizontal menus. But now our little centering trick doesn’t work. https://codepen.io/ohansemmanuel/full/ybMwpj/, https://codepen.io/ohansemmanuel/full/NjpmWY/, https://codepen.io/ohansemmanuel/full/RVpOaV/. Let's work with a small example to help make all of this text makemore sense. Because no one loves ugly designs, let’s have some very basic styling: The first few lines, 1 -5 explicitly sets the width and height of the root elements to 100%. Also, Happy Christmas folks (for those that celebrate it). It only took me 1/2 the day, but I figured it out! I see your point now — I’ll keep that in Mind for CSS Naked Day. background-position: left top; WOOT! Percentages are the prevalent method to achieve a fluid grid layout in responsive designs and will come in useful here.For example, take the below familiar HTML into consideration:And we’ll add the following CSS:Areas of note are: 1. So the aim; to use a standard list to hold text-based links, and generate a horizontal bar. . It was a huge pain to get rid of the unnecessary lists in WordPress. Am I missing something? Tryed using a min-width hack for ie6/7, (yours actually!) @Mogly: Yep, you are right. The main axis is horizontal by default, so the items flow into a row. 2. First we are going to create a HTML list by using Unordered List (ul) and List Item (li) elements. Many developers struggle while working with images. But i must admit it´s not a necessary code, the navigation also works without lists. }, As you can see it works fine in every browser non-ie based. Hi Chris, your code seems to work in Opera, Safari and Firefox but neither IE6 or 7 seem to like it, not sure if its an issue with my code but im rather desperate to get this working! ul#horizontal-list li { Fixed widths are unable to consistently fill the responsive container, as the below image illustrates.So we need to use percentages to accomplish this. Cheers for that Chris, unfortunately this is going to be a joomla template, the UL’s are generated by joomla so not much i can do there, guess il have to go for a new look! float: left; I’ve been using the following code as a standard for my nav, and it’s worked famously: