I am very picky and want to create a menu going across the page with spans and divs (well, I have navs and spans as I am trying in html5, but it isn’t necessary so I have simplified my question!). What it boils down to is basically this.
I have this code:
< html>
< head>
< title>Test< /title>
< style>
body * { border: 1px solid black; background-color: #999999; }
span { float:left; display: block; width: 33.33%; margin: 5px; }
.page { margin: 10px; background-color: #0000ff; }
.menu { margin: 5px; background-color: #00ffff; }
< /style>
< /head>
< body>
< div class='page'>
< div class='menu'>
< span>one< /span>
< span>two< /span>
< span>three< /span>
< /div>
< /div>
< /body>
< /html>
And I want to make it so that my spans all fit inside the blue div. perfectly.
I used to have a table which displayed this perfectly, but trying to write my code neater. Any advice? 🙂
Many thanks in advance!
Bob
What I ended up with was basically a combination of a few of them, but the actual answer I was after was to basically set all the borders/margins/padding of what used to be my span tags to 0 then use my anchor tags as block elements to add borders/margins etc to. Hopefully will work in all browsers and is a neat solution.
Thanks to you all for your help – couldn’t have gotten to this without you! 😀
Real-World js fiddle
HTML:
CSS: