Sorry for the title, what I'm trying to do is have several unordered lists, with maybe 10 - 15 items within them, span across the users screen side-by-side. I want the number of columns across to change based on the users screen size, with those "pushed off" to be placed underneath the lists.
So, imagine I have 3 unordered lists. If the users screen is wide enough I want them displayed as such:
Title 1 Title 2 Title 3
stuff stuff stuff
However, if the users screen isn't wide enough, I want the third column to be displayed underneath the first:
Title 1 Title 2
stuff stuff
Title 3
stuff
I'm eventually going to be having these tables/columns/unordered list (whatever) generated dynamically with PHP as the number required will be user dependent. But I first need to know the proper HTML and/or CSS to generate the code.
Thanks. That actually worked perfectly. Only one minor problem is if a list is shorter, as in, fewer li elements, the column moves underneath that one instead... this won't be as issue for me as I'll make sure all elements have the same number. Can I specify a height to fix the problem? (Yes it does)
As for definition lists, why should I use them in place of ul's? Thanks!
Follow up question: how do you center the columns? (Not the text inside...)
Sorry to post again, but I'm having difficulties getting the columns to be centered horizontally. When I do get them centered, then the far right column doesn't move when the screen is resized. (Well, it does eventually move, but not the moment the screen is smaller than the column, so what happens is some of the column is off screen...)
Not interested in validation ATM. Just testing out concepts and processes (This isn't the HTML that will be on my site...). Are you saying I can't center the div because my html isn't properly validated?
Invalid HTML can easily stop the CSS from working properly. When the CSS doesn't work as expected the most obvious thing to check first is to make sure that the HTML is valid.
Not interested in validation ATM. Just testing out concepts and processes (This isn't the HTML that will be on my site...). Are you saying I can't center the div because my html isn't properly validated?
No, I'm saying your ul lists are not formed correctly.
Your div is not centered because you haven't told it to be.
Thanks. I'll work on that right now. I've set my div's margin's to auto before, however, I can't set the width to 100% and have everything aligned. I have to specify an exact width. Which kinda defeats the purpose of what I'm trying to do.
My doctype should be valid for HTML5 no? Or is it because I haven't properly validated my code? I'll check on that too.
Ok, I fixed my code so that I don't have text within the ul's. Was using it because it worked... so as an aside, how do you get a title for the ul's?
Works just how I want it to, except that the boxes aren't centered. If I put in a width for the wrapper, then the columns don't shift appropriately. Same thing if I add padding or margin... I don't want any part of the columns disappearing off the side of the screen.
Thanks. I'll work on that right now. I've set my div's margin's to auto before, however, I can't set the width to 100% and have everything aligned. I have to specify an exact width.
You can't center a 100% width element. It takes the full width of it's container.
They don't center because you have them floated left. Your original question asked how to line them up and drop them to the next line when the screen narrowed...that's how floats act.