Can a div with a certain height (in CSS) automatically scale?

I set the div to height:100px; width:50px, but when the content of the div changes dynamically, I want the height to adapt to the change.

What should I do?

+3
source share
3 answers

Like others, mini-height and minimum width are what you need. This is a css rule and is applied as follows:

#someDivName {

min-height: 100px;
min-width: 50px;

}

Now your div will be 100px by 50px, but if the content inside is larger, it will adapt to change. Like the others that I was told about earlier, the min properties do not work in IE6, but in any case, it adores IE6 more. Even major sites like youtube have stopped supporting it.

+1
source

-

min-height: 100px;

div 100 , .

+6

minimum height is good practice. Also, instead of expressing the height in "px", use "em", which will scale with the current font.

+1
source

Source: https://habr.com/ru/post/1741582/


All Articles