Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Stopping divs from moving when window is resized?

Featured Replies

I am making a website for a friend who is very particular about what he wants. He is designing the style, I am simply making it appear on screen so to speak.

 

The layout consists of a wrapper div (98% wide, centered) with a header across the top and a footer across the bottom.

 

The menu is on the left hand side of the screen (120px wide).

Then there is the main content to the right of the menu div (floated left to butt up to the menu div).

 

This main content div is split into columns, with one column (<div id="col1">) which is 180px wide, followed by another div that contains a large image.

 

The site looks right in full screen, but at 1024x768 the divs move. The "col1" div moves UNDER the Menu div, and the image div moves below that.

 

The whole point of the site is to "grow" with the content. If the content grows longer, then the website scrolls downwards (this works OK). If the content grows wider than the screen, the website again can scroll sideways. It is this bit that fails as it moves the divs.

 

How can I make it so that a resized (or viewer with a smaller screen) sees the site without the divs moving around?? I have a feeling this is something I have done with the way I have placed the divs.

 

Thanks in advance guys.

  • Author

Hmm, maybe this is where I am going wrong as I am using a mix of the two rather than either one or the other. But I won't be able to get the strict layout using percentages only. :/

 

Would a link make a difference?

If you use percent for your wrapper width, but used fixed for the other divs only your wrapper will adjust it size. This will cause your other divs to move within the wrapper itself when the page is resized.

  • Author

If you use percent for your wrapper width, but used fixed for the other divs only your wrapper will adjust it size. This will cause your other divs to move within the wrapper itself when the page is resized.

Thanks for that, this is definately the issue I have.

 

Problem is the requirement to have "fixed sizes" on certain elements, yet "fluid sizes" on others.

 

I think I know which way to look at it though, thanks for the help. Much appreciated.

You need to add a 'margin' that accords to your layout. Add:

 

#box {

margin: 0 auto 0 auto;

}

 

 

or

 

#box {

 

margin: 0 20% 0 20%;

}

 

This works with all browsers.

 

Visit creativeshelf.co.uk for more tutorials and tips.

  • Author

Thanks for the advice. This is a different approach to the one I was going to take, but being cross-browser compatible makes this more interesting.

 

Thanks, will look at this in more detail.

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.