Similar Question:
Aligning image to center inside a smaller div
I am facing an issue related to CSS 3. Here is a snippet of my HTML code:
<div id="main" style="width: 320px; height: 400px;">
<img src="test.jpg" height="400" />
</div>
The dimensions of the test.jpg file are unknown, and it could vary in width. I want the image to be centered within the "main" id (even if parts of the image exceed the boundaries). How can I achieve this?