This looks like a very simple problem but I can't find the answer:
I want to center a div with fixed width of 500px. Markup and styling is as follows:
<div>
Lorem ipsum dolor sit amet, diceret delectus ea quo, ne eum essent legendos tacimates. Vel at perfecto omittantur. Iusto dolores sed an, error copiosae at his. Laoreet veritus vocibus te mel. An eos assum nobis vituperata, pro ad labitur facilis.
</div>
body {text-align:center;}
div {display:inline-block;width:500px;}
This works well when the viewport is wider than my div. However when the viewport gets smaller than my div, it is no longer centered but overflows to the right. I want my div to overflow on both sides of the viewport so it stays centered. Is this possible with CSS?
body {text-align:center;}
div {display:inline-block;width:500px;}
<div>
Lorem ipsum dolor sit amet, diceret delectus ea quo, ne eum essent legendos tacimates. Vel at perfecto omittantur. Iusto dolores sed an, error copiosae at his. Laoreet veritus vocibus te mel. An eos assum nobis vituperata, pro ad labitur facilis.
</div>