<div class="settings">
<p>Change the container width:</p>
<a href="#" data-width="100px" class="btn btn-default">100px</a>
<a href="#" data-width="200px" class="btn btn-default">200px</a>
<a href="#" data-width="300px" class="btn btn-default">300px</a>
<a href="#" data-width="400px" class="btn btn-default">400px</a>
<a href="#" data-width="500px" class="btn btn-default">500px</a>
<a href="#" data-width="auto" class="btn btn-default">Full-width</a>
</div>
<div class="my-container">
<div class="image-wrapper">
<div class="responsive-container">
<img src="https://placeholdit.imgix.net/~text?txtsize=240&txt=3200%C3%971800&w=3200&h=1800" alt="My responsive image" />
</div>
</div>
<p>This is a paragraph below the image</p>
</div>
.image-wrapper {
max-width: 3200px;
max-height: 1800px;
background-color: rgba(0, 0, 0, 0.05);
.responsive-container {
width: 100%;
padding-bottom: 56.25%;
position: relative;
img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
}
.my-container {
width: 500px;
margin: 0 auto;
}
.my-container, .settings {
text-align: center;
}
.settings {
margin: 15px;
}
View Compiled