bootstrap responsive images

Bootstrap Responsive Posts and images Fit with SVG frame image

To make a Responsive web design is a very critical job. Because there are many devices and their screen size exists. A good responsive design works well on all screen sizes and resolutions. Thanks to bootstrap which make our job much easier with its grid layouts. Making a responsive design only with css and not using additional JavaScript is another important issue.

In this tutorial I am making a three column posts gallery with images fit according to height and width of the responsive view port. I am also using a svg image as frame in front of the post image to make a beautiful frame illusion of the post  image. So lets start making it. After this tutorial I shall provide all source files to download for your projects.

First we make a file index.html and link bootstrap-4 css and js files to the template. and then write following html structure in it.

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>blue-post-gallery-2</title>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/Features-Boxed.css">

</head>

<body>
<div class="features-boxed">
<div class="container">

<div class="row justify-content-center features">

<div class="col-lg-4 item">
<div class="box">
<div class="post-image-wrapper">
<div class="post-image-container">
<div class="post-image-holder"><img src="assets/img/truck.jpg"></div>
<div class="post-background-img"></div>
</div>
</div>
<h3 class="name">Works everywhere</h3>
<p class="description">Aenean tortor est, vulputate quis leo in, vehicula rhoncus lacus. Praesent aliquam in tellus eu.</p><a class="learn-more" href="#">Learn more »</a>
</div>
</div>
<div class="col-lg-4 item">
<div class="box">
<div class="post-image-wrapper">
<div class="post-image-container">
<div class="post-image-holder"><img src="assets/img/truck.jpg"></div>
<div class="post-background-img"></div>
</div>
</div>
<h3 class="name">Works everywhere</h3>
<p class="description">Aenean tortor est, vulputate quis leo in, vehicula rhoncus lacus. Praesent aliquam in tellus eu.</p><a class="learn-more" href="#">Learn more »</a></div>
</div>
<div class="col-lg-4 item">
<div class="box">
<div class="post-image-wrapper">
<div class="post-image-container">
<div class="post-image-holder"><img src="assets/img/truck.jpg"></div>
<div class="post-background-img"></div>
</div>
</div>
<h3 class="name">Works everywhere</h3>
<p class="description">Aenean tortor est, vulputate quis leo in, vehicula rhoncus lacus. Praesent aliquam in tellus eu.</p><a class="learn-more" href="#">Learn more »</a></div>
</div>
<div class="col-lg-4 item">
<div class="box">
<div class="post-image-wrapper">
<div class="post-image-container">
<div class="post-image-holder"><img src="assets/img/truck.jpg"></div>
<div class="post-background-img"></div>
</div>
</div>
<h3 class="name">Works everywhere</h3>
<p class="description">Aenean tortor est, vulputate quis leo in, vehicula rhoncus lacus. Praesent aliquam in tellus eu.</p><a class="learn-more" href="#">Learn more »</a></div>
</div>
<div class="col-lg-4 item">
<div class="box">
<div class="post-image-wrapper">
<div class="post-image-container">
<div class="post-image-holder"><img src="assets/img/truck.jpg"></div>
<div class="post-background-img"></div>
</div>
</div>
<h3 class="name">Works everywhere</h3>
<p class="description">Aenean tortor est, vulputate quis leo in, vehicula rhoncus lacus. Praesent aliquam in tellus eu.</p><a class="learn-more" href="#">Learn more »</a></div>
</div>
<div class="col-lg-4 item">
<div class="box">
<div class="post-image-wrapper">
<div class="post-image-container">
<div class="post-image-holder"><img src="assets/img/truck.jpg"></div>
<div class="post-background-img"></div>
</div>
</div>
<h3 class="name">Works everywhere</h3>
<p class="description">Aenean tortor est, vulputate quis leo in, vehicula rhoncus lacus. Praesent aliquam in tellus eu.</p><a class="learn-more" href="#">Learn more »</a></div>
</div>
</div>
</div>
</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
</body>

</html>

In above html code there is a css file which is liked is “Features-Boxed.css”. This css code is making our bootstrap example responsive.

 

.features-boxed {
color: #313437;
background-color: #eef4f7;
}

.features-boxed p {
color: #7d8285;
}

.features-boxed h2 {
font-weight: bold;
margin-bottom: 40px;
padding-top: 40px;
color: inherit;
}

@media (max-width:767px) {
.features-boxed h2 {
margin-bottom: 25px;
padding-top: 25px;
font-size: 24px;
}
}

.features-boxed .intro {
font-size: 16px;
max-width: 500px;
margin: 0 auto;
}

.features-boxed .intro p {
margin-bottom: 0;
}

.features-boxed .features {
padding: 50px 0;
}

.features-boxed .item {
text-align: center;
padding: 3px;
}

.features-boxed .item .box {
text-align: center;
padding: 7% 2%; 
background-color: #fff;
margin-bottom: 30px;
margin: 0 auto;
height:100%; /* to make posts equual heights */
}

.features-boxed .item .icon {
font-size: 60px;
color: #1485ee;
margin-top: 20px;
margin-bottom: 35px;
}

.features-boxed .item .bg-frame {
font-size: 60px;
color: #1485ee;
margin-top: 20px;
margin-bottom: 35px;
margin-left: 0px;
}

.features-boxed .item .name {
font-weight: bold;
font-size: 18px;
margin-bottom: 8px;
margin-top: 8px;
color: inherit;
}

.features-boxed .item .description {
font-size: 15px;
margin-top: 15px;
margin-bottom: 20px;
}


.post-image-wrapper {
width: 300px;
height: 200px;
max-height:70vh;
max-width: 60vw;
margin: 0 auto;
}

.post-image-container {
position: relative;
width: 100%;
left: 0;
top: 0;
}

.post-image-holder {

min-height: 100%;
min-width: 100%;
font-size:12px;


}

.post-image-holder img {
/*
height: 150px;
margin: 8px 0 0 5px;
width: 95%;
min-width: 95%;
min-height: 100%;
*/
width:98%;
margin-top:3px;
height:155px;
max-height:55vh;
vertical-align: middle;


}


.post-background-img {
background-image: url("../../assets/img/post-blue-frame.svg");
width: 100%;
height: 200px;
max-height:65vh;
position: absolute;
background-position:top;
left: 0px;
top: 0px;
z-index: 1;
background-repeat: no-repeat;
background-size:100%;

}

There are also two images used in this example which are residing in image folder. 1st is “truck.jpg” which is example post image and 2nd  is “post-blue-frame.svg” which performing as frame for image.

The source code and file can be download here 


 

Leave a Reply

Your email address will not be published. Required fields are marked *

Go to Top