<div class='img-thumbnail'>
<img src="a.jpg" class='img-fluid'>
</div>
This particular code snippet is from an HTML file using Bootstrap 4 CSS. It displays an image inside a styled box. Adding an h4 heading places it below the image, still within the box.
<div class='img-thumbnail'>
<img src="a.jpg" class='img-fluid'>
<h4>filename:a.jpg</h4>
</div>
However, when attempting to align the heading to the right using either the Bootstrap .float-right
class or inline style style='float:right'
, the element shifts to the right but goes outside the thumbnail box. Assistance is needed to resolve this issue.
<div class='img-thumbnail'>
<img src="a.jpg" class='img-fluid'>
<h4 class='float-right'>filename:a.jpg</h4>
</div>
In Bootstrap 3, the .pull-right
class was used for similar alignment, ensuring the element stayed within the thumbnail box on the right side.
Here's the full code:
<div class='container'>
<div class='row'>
<div class='col-3'>
<p class='lead'>LOL</p>
<ul class='list-group'>
<li class='list-group-item active'>Something 1</li>
<li class='list-group-item'>Something 2</li>
<li class='list-group-item'>Something 3</li>
</ul>
</div>
<div class='col-9'>
<div class='img-thumbnail'>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Google_%22G%22_Logo.svg/2000px-Google_%22G%22_Logo.svg.png" class='img-fluid'>
<h4 class='float-right'>$9.99</h4>
</div>
</div>
</div>
</div>