Reputation: 89
I have a sidebar DIV on my web page that has buttons. I have the width of the sidebar set as follows:
width: 20%;
but when the browser size is reduce then there's sometime not enough space for the buttons. Is it possible for me to have the width as 20% but also specify a minimum in px?
Upvotes: 2
Views: 298
Reputation: 72667
Yes. The W3C CSS recommendation generally does not require that units for different dimensions like width and min-width be the same. (Not quite relevant side note: You can even mix different units for dimensions like padding, e.g. padding: 2px 1em;
.)
Upvotes: 1
Reputation:
Using “min width”.
min-width: 20px;
for example.
But if you want its width to always be at least the size of whatever is contained, consider using display: table-cell;
Upvotes: 0
Reputation: 85802
Yes. This is pretty common, too. Have fun!
And protip: you can always just try and find out ;)
Upvotes: 3