Is it good to add min-width, max-width, min-height, max-height always in any type of layout fixed or liquid?
Is it good to add min-width, max-width, min-heig开发者_Go百科ht, max-height always in any type of layout fixed or liquid?
No.
The concept of cascading style sheets is that there are rules that dictate other rules up and down the chain (hence the inclusion of "inherit" as a property).
For example, if you use a container div, and you specify an max and min, then you would need to recalculate every time you adjust a div underneath it, for example if you wanted the header to be wider.
Conversely, if you have a container div with a fixed size, instead of making the header the same width (if you are trying to fill it), you can just specify a percentage, instead of having to do the math for every div down the cascade.
This becomes even more important the more stylesheets you include, and the more complex your pages are.
If your layout is fixed (which means you have defined width/height) then the min- /max- rules will be ignored as the width/height have precedence over those..
Of'course you might want to use min-/max- rules for other elements inside of the fixed ones. (if there is reason)..
So, you should only use them if they are required by the layout logic..
I agree with @Cryophallion. It also depends if you are expecting controlled static data, or dynamic data. I.e. if you have a DIV that holds a dynamic object such as a image, you may want to limit the size it takes on the page. This is to control the size the image takes, because you may not know the size of the image before hand.
精彩评论