Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of width and min-width

When writing a webpage in html, can you use two different quantitative measures for width and min_width?

For example can you use:

width: 90%
min-width: 600px

Do they both have to be the same unit of measurement (px or %) or does it not matter? I'm trying this in a webpage but it is not working. I am using this to minimally size a jqGrid table, but I wouldn't think that would matter.

like image 929
WildBill Avatar asked Feb 27 '12 21:02

WildBill


2 Answers

These can definitely work together. The width declaration will be set 90% of whatever it's container width is. The min-width makes it so that element has to be at least 600px wide.

like image 102
Joel Eckroth Avatar answered Nov 15 '22 22:11

Joel Eckroth


It should be min-width: 600px;. They can be used together and can use different units. See an example here. The element will not shrink to any smaller than the min-width, if there is enough space it will use the width value, so in this case 90% of the available space.

like image 23
slashnick Avatar answered Nov 15 '22 22:11

slashnick