Brett Brett - 2 months ago 7
CSS Question

Using a percentage margin in CSS but want a minimum margin in pixels?

I have set a

margin: 0 33% 0 0;
however I would also like to make sure the margin is at least a certain
px
amount. I know there is no
min-margin
in CSS so I was wondering if I have any options here?

Answer

Place a div with a % width and a static min-width to the right of your element.

<div style="position:relative; float:left; margin:0">
<div style="position:relative; float:left; width:33%; min-width:200px">
Comments