I have code like this:
<div class="container">
<img src="img_url" alt="" />
</div>
Container’s width has set on 600px but if image is bigger, container’s width should adjust to image size.
How I should fix my css?
.container {
margin: auto;
margin-bottom: 30px;
padding: 10px;
width: 400px;
background-color: #2a2929;
border: 1px solid #212020;
}
.container img {
display: block;
margin-left: auto;
margin-right: auto;
}
add to the container img
that should keep the image within the container