- This topic is empty.
August 30, 2018 at 6:58 pm #275819SimonBParticipant
Two beginner questions. First one is more important to me:
1_ I read in a book that it is a general rule of thumb for settings the heights of divs “to not set” them. The first reason that I could think of -and sounds right- is that the content of the div may change, we can not predict, for example, how long or how big(font-size) a paragraph may become. But I wonder how much general this rule REALLY is? What if there’s a div that contains EXACTLY 4 images with known sizes(for example in a news website)?! If we’re using media queries for other screen sizes, is it still a bad practice to set the heights? is min-height as bad?
2_ what’s the difference between the usage of the min-width and the max-width? I mean in which scenarios you use each? which one is used more?August 30, 2018 at 10:10 pm #275821BeverleyhParticipant
Yes, not setting heights is a general rule of thumb, although, as with most things, it depends on what you’re doing. Using media queries to change heights at given breakpoints is perfectly acceptable. I would take the rule to be more applicable to divs containing text, and would think it relates more to situations with fluid widths since you can’t accurately predict how tall containers will stretch to at every incremental pixel change to accommodate the text inside (words are different lengths, lines break unpredictably). The idea is to let the content flow and create whatever height is needed to contain it. Images are a bit different and are more predictable.
Max-width = don’t let this element be any bigger than this specified value.
Min-width = don’t let this element be any smaller than this specified value.
For more advice on how/when to use them, try Googling “width min-width max-width” and read some of the articles that come up. Your question is otherwise too general for us to answer, but if you can provide code and examples of real-life usage/issues you’re having, we might have an easier time.
- The forum ‘CSS’ is closed to new topics and replies.