Is there a way to horizontally center an image inside a div, regardless of the size difference between the image and its wrapper?
I am aware of a Javascript solution, but I am specifically looking for a CSS-based solution.
The following sample code does not achieve the desired outcome (the HTML should remain unchanged, only the CSS can be modified):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>my test</title>
</head>
<body>
<div id="wrapper" style="width:300px;margin:0 auto;">
<div id="image_content" style="margin:0 auto;">
<img src="image_small_then_300_or_bigger.jpg" />
</div>
</div>
</body>
</html>
Thank you!