I am trying to create a container on a site that.
Inside this container I want 3 rows, each row has an image. The image itself it quite large, however I wanted to image to be restricted to the size of it’s parent. How, even with a massive trail of h-100
, the images when rendered are nearly 5 times the size of the viewport.
Here is my progress.
To clarify I do not want the images to overflow, I need them all to shrink to not go outside the parent
<!-- Bootstrap 4.1.x / Twitter-Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<!-- Body -->
<div id="main-container" style="opacity: 0.5;">
<div class="container-fluid" style="position: fixed; bottom: 7%; height: 70vh;">
<div class="row h-100">
<div class="col h-100">
<div class="row ">
<img class="rounded-circle img-fluid" width="100%" height="auto" src="https://via.placeholder.com/1920x1080.png" style="border: .2rem solid #1a4579;">
</div>
<div class="row ">
<img class="rounded-circle img-fluid" width="100%" height="auto" src="https://via.placeholder.com/1920x1080.png" style="border: .2rem solid #1a4579;">
</div>
<div class="row ">
<img class="rounded-circle img-fluid" width="100%" height="auto" src="https://via.placeholder.com/1920x1080.png" style="border: .2rem solid #1a4579;">
</div>
</div>
</div>
</div>
</div>
6
Answers
try this:
use add this css property to image this way or externally as your preference.
Slight changes in HTML structure and added CSS.
Try this:
Try this:
And
width="100%" height="auto"
from images.I based the example on the fact that you wish to keep always the images width at a minimum width of 100%, if you dont want that, I can still change it.
Process:
I added the class
overflow
to your.col
div that contain all the row image.Then the goal is to hide your image height with
overflow:hidden
and then centering image withposition:absolute
as below:(You might have some problem with js as it is using
position:absolute
please provide working example for more.)