How to center a div with a relative width?


I have a <div> which is styled as following:

    width: 70%;

To center a div, there is the possibility to set the margin to auto (margin: 0 auto;) but this only works if I have a fixed size(e.g. 400px). So how can I center my div with relative width?

margin: 0 auto will also work for percentage divs. The side margins will be calculated based off the percentage of the width.