I have the following section of code that I am having issues with:
I have a container with a width of 95%
within this container I have an alerts bar with a width of 100%
under this I have an area that is displaying user information with a width of 50px; and is floated left
I then have another area called text message that I would like the width to be 100% but it seems to go under the above box instead of next to it. Why?
<p class="alert">Alert Message Area</p>
<p class ="alertMessage"><span class="bold">Important:</span> Your Account is set to Pacific/Auckland Time. The Time is now <span class="bold">9:30AM</span> on <span class="bold">29th May 2012</span></p> <span class="close"></span>
<span class="userImage"><img src="_assets/images/ava.png" width="46" height="45" alt="Ava"></span>
I’m not sure what you’re showing me there. If you open that code I posted in a .html file, you’ll see what I was doing in your browser. I need to see what code you are using and what you don’t like about it to help with this.
You’ve got a number of flaws in there – like the box model. You’re declaring a lot of widths on elements that to be frank, shouldn’t even HAVE widths… Take your alertMessage class – the default behavior of a display:block element is to auto-size to fit the full available width – setting 100% width + 5px padding + 3px border makes it whatever your 100% width is PLUS 16 px – larger than the box it’s inside of! (unless you’re in quirks mode on IE by omitting your doctype or having code before the doctype – which would be “welcome to 1997”)
It also feels a bit DIV heavy – I’m on the tablet right now so I can’t really dig into it too deep, but I’ll try to remember to take a closer look when I’m back at my workstation.
On the whole though, you went overboard declaring widths on things that shouldn’t have widths – set width once on the outside, set it for the float, let everything else use flow and auto-fit to go where it wants. Some of those widths are so small – do I dare ask what absurdly undersized font size you’re declaring in px?
Though I suspect you are also getting confused by the natural behavior of block level containers and floats – where the container goes behind the float even if it’s display:inline and textnode content wraps around it… something else setting an overflow state can fix.