Joe Morano Joe Morano - 11 months ago 38
CSS Question

How to set a max-width as percent AND pixels?

How can I prevent the width of a div from expanding beyond a percent AND a pixel? In other words, the browser should calculate the pixel value of the percent, and then choose the lower of the two values.

If I were to set them both like this:

the asset pipeline would simply choose the second one and ignore the first one.

Answer Source

This sets the width to 20% but caps it at 100 px.