views:

913

answers:

6

I've just spent the last few weeks learning how to properly design a layout. I basically thought I had everything perfect with my website layout and was ready to go about transferring the coding to Wordpress... and then I accidentally resized my web browser and discovered that all of my div layers were overlapping each other.

Here's what it looks like: http://img.photobucket.com/albums/v703/dollyshots/example.jpg

Basically it looks as though it's mainly my center content div that is being squeezed out, as well as my header image and navigation with are in the same top div. My footer is also squeezed down as well. I've searched the Internet for a solution to this problem and can't seem to find a thing.

How do I fix it so that my divs stay in place when the browser is resized? Some help would be very much appreciated.

A: 

Can you post some of your CSS?

The simplest way is to give all of your columns relatively sane width settings so that the size of the browser window doesn't affect the size of your layout. Getting fluid-width column(s) to behave is more complex and depends more on the specifics of your layout.

Walter Mundt
http://lifesgarbage.com/rebnationcss.cssHere's the link to my css. Thanks for your help so far!
Rebecca
+1  A: 

Hi rebecca, as Walter said your CSS would be helpful. But, the main problem is that the content in the div is overflowing to other divs because the the content's div cannot contain all the content.
In your css, try setting the div's overflow property to either auto (shows scrolls bars) or hidden (to just hide the content if it goes outside's the div) e.g.

overflow:auto;

or

overflow:hidden;
Enoex
I tried your suggestion but I'm not exactly sure where to put the overflow property. I put it in the container div holding all of the rest of the content and it didn't do anything unfortunately. Nevertheless, here's a link to my entire CSS. I wasn't sure what would really be relevant or not. Thanks so far for the help. I'm hoping there's an easy way to solve this. :(
Rebecca
http://lifesgarbage.com/rebnationcss.css
Rebecca
The overflow would go in whatever div that contains the "This is a subheading" text. If you put it in a parent div above the div that holds the heading text it may not inherit properly. Could you post the HTML as well? Also, as was previously said, flexible width are generally a better idea, but would require you to refactor your css.
Enoex
The overflow didn't seem to work to me, sadly. I find that the pictures also get skewed up in the dark header area, which has my site name and my navigation. I uploaded my test page just so you can see it working (not not working). http://lifesgarbage.com/rebnation.html
Rebecca
In your #content add overflow:hidden e.g.,#content { ...your code... overflow:hidden;}That should fix the image expanding past the div. You also might want to make those border images transparent (either .png or use a transparent .gif)Nice site btw.
Enoex
I tried the overflow:hidden where you told me to put it and now the content is merged with the left sidebar. I just uploaded the css file so you can check out the address of the test page and see for yourself. I'm not sure why my new layout is reacting the way it is to a simple browser resize. Basically I just want a horizontal scrollbar to appear along the bottom of the browser so the viewer can resize the window and still scroll through the site. I don't really want any content to disappear or anything.Sorry if I wasn't clear at first.
Rebecca
A: 

Express your widths and font-sizes in ems. Here's a good calculator: http://riddle.pl/emcalc/

Percentages will work, too.

Check the css in stackoverflow, and try resizing the zoom level in your browser here - you'll see everything resizes nicely at any zoom level.

George Sisco
A: 

Check out the min-width property. Another option is applying another stylesheet when the viewport width is below x pixels with CSS3 Media Queries like so:

@media all and (max-width: 30em) {
  /* Alternative narrow styles */
}

or so:

<link media="all and (max-width: 30em)"
      rel="stylesheet" href="narrow.css" />

CSS3 Media Queries are still not widely supported, so you might want to look into a solution that applies the "narrow" style sheet with JavaScript through the window.onresize event. I'd recommend jQuery for such a solution.

asbjornu
A: 

I figured it out. Turns out that the width of my center content margin was dictated by margins instead of just a direct width (ie. 500px). So whenever the page was resized, the margins on the sides of the browser tried to stay as they were, thus making the entire column smaller. I just had to get rid of the margins and specify where I wanted the column to sit on the page and just justify a width for it.

Rebecca
A: 

you can also try the min-width. i am assuming the center div is fluid and sidebars are fixed-width.

barraponto