Reputation: 12
I have a Div which contains a header and a navigation menu(horizontal) . When the user resizes the page the menu gets distorted and the links mov out of the div. How to limit this such that the menu will remain intact on page resize
Upvotes: 0
Views: 1232
Reputation: 330
To limit the size of an element you can use the min- and max- prefixes. To set the minimum and maximum size. Combined with the width or height as usual. For example:
#content {
width: 50%;
min-width: 300px;
max-width: 1900px;
}
Will never be narrower than 300px or wider than 1900px, but on a 1280 resolution it will be rendered as 640px.
It is widely supported: http://www.caniuse.com/#search=min-width
Upvotes: 0
Reputation: 17724
Fix the size for your div using CSS. If your div has a size assigned in pixel or em, the size of the screen won't matter. Scroll bars will be added by the browser, and your content will not get distorted.
#myDiv
{
width: 900px;
}
Upvotes: 1