Jump to content
Zilee

Stop a div from moving.

Recommended Posts

Is it possible to stop a centered div using % to stop moving at some point during a re-size? Because currently my div is centered but if I re-size too much is goes below the menu while I would want it to stop at the menu.

Edited by Zilee

Share this post


Link to post
Share on other sites

You can set the min-width attribute to some px, em or pt value to prevent it getting squished too small.

Share this post


Link to post
Share on other sites

When you use the % values the div is adjusted as a percentage of the view port's width, so its going to change. The max-width modifiers could be used or just fixed widths

Share this post


Link to post
Share on other sites

I've wondered about reasons behind that property. Thanks.

Share this post


Link to post
Share on other sites

No problem its all in the documentation at w3.org.

Share this post


Link to post
Share on other sites

percentages are relative units. if you had the div in a 1000px tall parent div, than 50% would work (max width would be 500px, half of the parent div). when dealing with relative units of measurements, you have to take context into consideration. I think often times max width is used when creating container div's whose widths are relative units (%) and you want keep the view port from over stretching in cases where the user may have a larger than anticipated resolution.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...