Images
Responsive Images
Images in Bootstrap 3 can be made responsive-friendly via the addition of the .img-responsive
class. This applies max-width: 100%;, height: auto; and display: block; to the image so that it scales nicely to the parent element.
To center images which use the .img-responsive
class, use .center-block
instead of .text-center
.
<img src="..." class="img-responsive" alt="Responsive image">
Image Shapes
Add classes to an <img>
element to easily style images in any project.
<img src="..." alt="..." class="img-rounded">
<img src="..." alt="..." class="img-circle">
<img src="..." alt="..." class="img-thumbnail">
Best Practices
For an image to be full-width on mobile (>768px), make sure the image size is at least 650px wide (assuming two-column layout). You will have to use row columns to constrain to the column for desktop.
Methods
- Constrain the image using a row column and check the Responsive Image checkbox
- constrain via a specific class targeted in CSS and then set specific class to width:100%; height:auto in media query for specified breakpoint
Hover Zoom
/*Utility Classes*/
.hover-zoom {position:relative; overflow:hidden;}
.hover-zoom img {
-ms-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
transition: all 0.2s ease;
-ms-transform: scale(1);
-moz-transform: scale(1);
-webkit-transform: scale(1);
transform: scale(1);
}
.hover-zoom:hover img, .hover-zoom img:hover {
-ms-transform: scale(1.1);
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
.hover-zoom:after {
color:#fff;
font-family:FontAwesome;
text-align:center;
content:"\f067";
position:absolute;
right:0;
bottom:0;
width:40px;
height:40px;
padding:10px 0;
background-color:rgba(55, 67, 90, 0.8);
z-index:2;
}
.hover-zoom:hover:after {background-color:rgba(55, 67, 90, 1);}