I am making a instagram type of feed and have a 4 images with a further 4 below those 4. I need to make a overlay which I can put words in front of all 8 images showing instagram followers and a link to their instagram.
I have most of it done but the overlay I cannot seem to get it to work. Any help would be appreciated, thanks in advance.
Josh
<ul class="images">
<div class="col-sm-3">
<img src="img/instagram/image-1.jpg" alt="Image Gallery" class="img-responsive">
</div>
<div class="col-sm-3">
<img src="img/instagram/image-2.jpg" alt="Image Gallery" class="img-responsive">
</div>
</ul>
Use o overlay div with position absolute covering the entire images container like the example....
.images{
position:relative;
display:inline-block;
}
.overlay{
position: absolute;
top: 0;
left: 0;
background: rgba(255,255,255,0.5);
width: 100%;
height: 100%;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
visibility: hidden;
}
.images:hover .overlay{
visibility: visible;
}
<div class="images">
<div class="col-sm-3">
<img src="http://via.placeholder.com/350x150" alt="Image Gallery" class="img-responsive">
</div>
<div class="col-sm-3">
<img src="http://via.placeholder.com/350x150" alt="Image Gallery" class="img-responsive">
</div>
<div class='overlay'>
<span>some text</span>
</div>
</div>
Like this? You can put whatever words in the overlay as you want. I used xs columns so you could see it fully.
.overlay{
display:block;
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
background-color:rgba(0,0,0,.5);
z-index:10;
}
.overlay h2{
color:#fff;
}
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="overlay">
<h2>Follow me on Insta</h2>
</div>
<div class="row images">
<div class="col-xs-3">
<img src="http://fillmurray.com/200/300" alt="Image Gallery" class="img-responsive">
</div>
<div class="col-xs-3">
<img src="http://fillmurray.com/200/300" alt="Image Gallery" class="img-responsive">
</div>
<div class="col-xs-3">
<img src="http://fillmurray.com/200/300" alt="Image Gallery" class="img-responsive">
</div>
<div class="col-xs-3">
<img src="http://fillmurray.com/200/300" alt="Image Gallery" class="img-responsive">
</div>
</div>
</div>
I think the below is what you need. I used flexboxes for layout.
* {
box-sizing: border-box;
}
.container {
display: flex;
justify-content: flex-start;
flex-flow: wrap;
width: 500px;
}
.item {
display: inline-block;
margin: 0 0.5em 0.5em 0;
position: relative;
}
.text {
opacity: 0;
background-color: rgba(0, 0, 0, 0.6);
position: absolute;
display: flex;
align-items: center;
justify-content: center;
width: 100px;
height: 100px;
top: 0;
}
.text:hover {
border: thin solid red;
animation: opac 0.3s ease forwards;
}
#keyframes opac {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="row-sm-12 container">
<div class="row-sm-3 item">
<img src="http://placehold.it/100">
<div class="text">Bla bla</div>
</div>
<div class="row-sm-3 item">
<img src="http://placehold.it/100">
<div class="text">Bla bla</div>
</div>
<div class="row-sm-3 item">
<img src="http://placehold.it/100">
<div class="text">Bla bla</div>
</div>
<div class="row-sm-3 item">
<img src="http://placehold.it/100">
<div class="text">Bla bla</div>
</div>
<div class="row-sm-3 item">
<img src="http://placehold.it/100">
<div class="text">Bla bla</div>
</div>
<div class="row-sm-3 item">
<img src="http://placehold.it/100">
<div class="text">Bla bla</div>
</div>
<div class="row-sm-3 item">
<img src="http://placehold.it/100">
<div class="text">Bla bla</div>
</div>
<div class="row-sm-3 item">
<img src="http://placehold.it/100">
<div class="text">Bla bla</div>
</div>
</div>
Related
I'm hoping to get some advice on creating a responsive card that will display the full height of an image on hover. I've been working on it for the past hour and have come up with a solution, which you can see in my jsfiddle file. However, it's not quite as responsive as I'd like it to be. I'd really appreciate any tips or recommendations you might have.
Here is my take: jsfiddle
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
gap: 2rem;
}
.card {
position: relative;
background: #eee;
display: flex;
flex-direction: column;
height: 420px;
}
.card .thumbnail {
position: relative;
width: 100%;
height: 275px;
}
.card:hover {
z-index: 999;
}
.card:hover .thumbnail {
height: auto;
}
.card:hover .details {
top: 100%;
}
.card .thumbnail img {
width: 100%;
height: 100%;
object-fit: cover;
transition: height 0.3s ease-in-out;
}
.card .details {
display: flex;
flex-direction: column;
position: absolute;
width: 100%;
background: blue;
bottom: 0;
height: 170px;
}
.card .details h1 {}
<div class="card-grid">
<div class="card">
<div class="thumbnail">
<img src="#" alt="Card Thumbnail">
</div>
<div class="details">
<h1>Card Title</h1>
<p>Card description goes here</p>
</div>
</div>
<div class="card">
<div class="thumbnail">
<img src="#" alt="Card Thumbnail">
</div>
<div class="details">
<h1>Card Title</h1>
<p>Card description goes here</p>
</div>
</div>
<div class="card">
<div class="thumbnail">
<img src="#" alt="Card Thumbnail">
</div>
<div class="details">
<h1>Card Title</h1>
<p>Card description goes here</p>
</div>
</div>
<div class="card">
<div class="thumbnail">
<img src="#" alt="Card Thumbnail">
</div>
<div class="details">
<h1>Card Title</h1>
<p>Card description goes here</p>
</div>
</div>
<div class="card">
<div class="thumbnail">
<img src="#" alt="Card Thumbnail">
</div>
<div class="details">
<h1>Card Title</h1>
<p>Card description goes here</p>
</div>
</div>
<div class="card">
<div class="thumbnail">
<img src="#" alt="Card Thumbnail">
</div>
<div class="details">
<h1>Card Title</h1>
<p>Card description goes here</p>
</div>
</div>
<div class="card">
<div class="thumbnail">
<img src="#" alt="Card Thumbnail">
</div>
<div class="details">
<h1>Card Title</h1>
<p>Card description goes here</p>
</div>
</div>
</div>
I am using position: absolute in order to prevent the card height from changing and disrupting the grid layout.
Thank you!
This question already has answers here:
CSS-only masonry layout
(4 answers)
Closed 1 year ago.
I am trying to make a gallery that is uneven and staggered by using images and colored divs that are not the same size. I have the columns set to a min of 352px and to auto-fit the screen. So the container with grid looks something like this:
display: grid;
grid-template-columns: repeat(auto-fit, minmax(352px, 1fr));
grid-gap: 20px;
The issue I am having is the tallest picture sets the height of the row and the divs that have the smaller images follow the same height. Is there a way to tell the items in the row to not all be the same size? Or rather just target certain items in each row and tell them to be a specific height?
.grey {
background: #D9D9D9;
}
.tan {
background: #DCCEC8;
}
.light-brown {
background: #DC997D;
}
.brown {
background: #814A3D;
}
.black {
background: #000;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(352px, 1fr));
grid-gap: 20px;
}
.grid > div {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
img {
max-width: 350px;
width: 350px;
}
.overlay {
position: absolute;
width: 350px;
height: 100%;
background: rgba(0, 0, 0, 0.05);
}
h4 {
text-transform: uppercase;
font-size: 26px;
color: #fff;
position: absolute;
z-index: 9;
}
h4:nth-child(2) {
bottom: 35px;
}
h4:nth-child(3) {
font-size: 18px;
margin: 5px 0;
bottom: 5px;
}
.fill {
max-width: 350px;
height: 100%;
width: 100%;
}
<div class='grid'>
<div>
<img class="thumbnail" src="https://picsum.photos/500/600" alt="person" />
<h4>Person One</h4>
<h4>#person1</h4>
<div class="overlay"></div>
</div>
<div><div class="tan fill"></div></div>
<div>
<img class="thumbnail" src="https://picsum.photos/300/220" alt="person" />
<h4>Person TWO</h4>
<h4>#person2</h4>
<div class="overlay"></div>
</div>
<div><div class="black fill"></div></div>
<div>
<img class="thumbnail" src="https://picsum.photos/700/700" alt="person" />
<h4>Person 3</h4>
<h4>#person3</h4>
<div class="overlay"></div>
</div>
<div>
<img class="thumbnail" src="https://picsum.photos/400/400" alt="person" />
<h4>Person four</h4>
<h4>#person4</h4>
<div class="overlay"></div>
</div>
<div>
<img class="thumbnail" src="https://picsum.photos/500/260" alt="person" />
<h4>Person Five</h4>
<h4>#pesron5</h4>
<div class="overlay"></div>
</div>
<div><div class="light-brown fill"></div></div>
<div><div class='brown fill'></div></div>
<div>
<img class="thumbnail" src="https://picsum.photos/600/220" alt="person" />
<h4>Person Six</h4>
<h4>#person6</h4>
<div class="overlay"></div>
</div>
<div><div class="black fill"></div></div>
<div>
<img class="thumbnail" src="https://picsum.photos/200/350" alt="person" />
<h4>Person Seven</h4>
<h4>#person7</h4>
<div class="overlay"></div>
</div>
<div>
<img class="thumbnail" src="https://picsum.photos/500/300" alt="person" />
<h4>Person Eight</h4>
<h4>#person8</h4>
<div class="overlay"></div>
</div>
<div><div class="tan fill"></div></div>
<div>
<img class="thumbnail" src="https://picsum.photos/250/250" alt="person" />
<h4>Person Nine</h4>
<h4>#Person9</h4>
<div class="overlay"></div>
</div>
<div>
<img class="thumbnail" src="https://picsum.photos/300/220" alt="person" />
<h4>Person Ten</h4>
<h4>#person10</h4>
<div class="overlay"></div>
</div>
</div>
Use height on the grid items. Moreover, the headings should be wrapped in a container and their default margins should be overwritten so that headings fit in container with image's height < 150px.
.grey {
background: #d9d9d9;
}
.tan {
background: #dccec8;
}
.light-brown {
background: #dc997d;
}
.brown {
background: #814a3d;
}
.black {
background: #000;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(352px, 1fr));
grid-gap: 20px;
}
.grid>div {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
}
img {
max-width: 350px;
width: 350px;
}
.overlay {
position: absolute;
width: 350px;
height: fit-content;
background: rgba(0, 0, 0, 0.05);
bottom: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
}
h4 {
text-transform: uppercase;
font-size: 26px;
color: #fff;
z-index: 9;
text-align: center;
margin: 0;
margin-bottom: 10px;
}
.fill {
max-width: 350px;
height: 100%;
width: 100%;
}
.grid-item {
height: fit-content;
height: -moz-fit-content;
}
<div class="grid">
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/500/1000" alt="person" />
<div class="overlay">
<h4>Person One</h4>
<h4>#person1</h4>
</div>
</div>
<div>
<div class="tan fill"></div>
</div>
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/1500/2000" alt="person" />
<div class="overlay">
<h4>Person TWO</h4>
<h4>#person2</h4>
</div>
</div>
<div>
<div class="black fill"></div>
</div>
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/700/1500" alt="person" />
<div class="overlay">
<h4>Person 3</h4>
<h4>#person3</h4>
</div>
</div>
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/400/100" alt="person" />
<div class="overlay">
<h4>Person four</h4>
<h4>#person4</h4>
</div>
</div>
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/500/200" alt="person" />
<div class="overlay">
<h4>Person Five</h4>
<h4>#pesron5</h4>
</div>
</div>
<div>
<div class="light-brown fill"></div>
</div>
<div>
<div class="brown fill"></div>
</div>
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/600/220" alt="person" />
<div class="overlay">
<h4>Person Six</h4>
<h4>#person6</h4>
</div>
</div>
<div>
<div class="black fill"></div>
</div>
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/200/150" alt="person" />
<div class="overlay">
<h4>Person Seven</h4>
<h4>#person7</h4>
</div>
</div>
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/500/300" alt="person" />
<div class="overlay">
<h4>Person Eight</h4>
<h4>#person8</h4>
</div>
</div>
<div>
<div class="tan fill"></div>
</div>
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/250/250" alt="person" />
<div class="overlay">
<h4>Person Nine</h4>
<h4>#Person9</h4>
</div>
</div>
<div class="grid-item">
<img class="thumbnail" src="https://picsum.photos/300/220" alt="person" />
<div class="overlay">
<h4>Person Ten</h4>
<h4>#person10</h4>
</div>
</div>
</div>
I started learning web programming and i want to test some features but there is a problem, when I bring the mouse on the above photos, the bottom ones change place like in the photo. The photos below are on the left in the first opening, while hovering on the top one, it shifts to the right.
Like this:
*{
box-sizing: border-box;
}
#gallery{
width: 1200px;
margin: 20px auto;
}
.item-container{
width: 25%;
float: left;
padding: 10px;
}
.gallery-item{
border: 1px solid #ccc;
transition: border 0.4s linear;
}
.gallery-item:hover{
border: 3px solid #777;
cursor: pointer;
}
.gallery-item img{
width: 100%;
height: 200px;
object-fit: contain;
background-color: #DCDCDC;
}
.description{
text-align: center;
padding: 15px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Art Gallery</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/1.jpg" target="_blank">
<img src="img/1.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/2.jpg" target="_blank">
<img src="img/2.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/3.jpg" target="_blank">
<img src="img/3.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/4.jpg" target="_blank">
<img src="img/4.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/5.jpg" target="_blank">
<img src="img/5.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/6.jpg" target="_blank">
<img src="img/6.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
</body>
</html>
How can i fix it?
Updated answer
Add outline instant of border
The problem with your border hover css
From
.gallery-item:hover{
border: 3px solid #777;
cursor: pointer;
}
To
.gallery-item:hover{
border: 1px solid #777;
cursor: pointer;
}
*{
box-sizing: border-box;
}
#gallery{
width: 1200px;
margin: 20px auto;
}
.item-container{
width: 25%;
float: left;
padding: 10px;
}
.gallery-item{
outline: 1px solid #ccc;
transition: border 0.4s linear;
}
.gallery-item:hover{
outline: 3px solid #777;
cursor: pointer;
}
.gallery-item img{
width: 100%;
height: 200px;
object-fit: contain;
background-color: #DCDCDC;
}
.description{
text-align: center;
padding: 15px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Art Gallery</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/1.jpg" target="_blank">
<img src="img/1.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/2.jpg" target="_blank">
<img src="img/2.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/3.jpg" target="_blank">
<img src="img/3.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/4.jpg" target="_blank">
<img src="img/4.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/5.jpg" target="_blank">
<img src="img/5.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
<div id="gallery">
<div class="item-container">
<div class="gallery-item">
<a href="img/6.jpg" target="_blank">
<img src="img/6.jpg" alt="" >
</a>
<div class="description">
description about image gallery item
</div>
</div>
</div>
</div>
I have a layout like this:
body {
text-align: center;
}
.link {
position: relative;
}
.info {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
text-align: center;
width: 100%;
height: 100%;
background-color: #263238;
color: #1DE9B6;
opacity: 0;
visibility: hidden;
}
.link:hover .info {
opacity: 1;
visibility: visible;
}
.col-md-3 {
margin-bottom: 30px;
}
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
</div>
</div>
When the layout gets small, and only one column is displayed horizontally, the div which is supposed to show on hover gets as big as the column, but I only want it to be as big as the fluid image. How would I need to achieve this?
Here is the codepen link: https://codepen.io/Kestvir/pen/gKVwLe
Just add display: inline-block to the link element
.link {
position: relative;
display: inline-block;
}
Or you can also add d-inline-block position-relative classes on the .link elements .
body {
text-align: center;
}
.link {
position: relative;
display: inline-block;
}
.info {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
text-align: center;
width: 100%;
height: 100%;
background-color: #263238;
color: #1DE9B6;
opacity: 0;
visibility: hidden;
}
.link:hover .info {
opacity: 1;
visibility: visible;
}
.col-md-3 {
margin-bottom: 30px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
<div class="col-md-3">
<div class="link">
<img class="img-fluid" src="http://image.tmdb.org/t/p/w300/c9XxwwhPHdaImA2f1WEfEsbhaFB.jpg" alt="img">
<div class="info">Info</div>
</div>
</div>
</div>
</div>
.col-xs-15,
.col-sm-15,
.col-md-15,
.col-lg-15 {
position: relative;
min-height: 1px;
padding-right: 10px;
padding-left: 10px;
}
.col-md-15 img {
height: 200px;
width: 200px;
}
.margin20
{
margin-top: 20px;
}
/*new set of column*/
.col-xs-15 {
width: 20%;
float: left;
}
#media (min-width: 768px) {
/*even if i remove this nothing happen*/
.col-sm-15 {
width: 20%;
float: left;
}
}
#media (min-width: 992px) {
.col-md-15 {
width: 20%;
float: left;
}
}
#media (min-width: 1200px) {
.col-lg-15 {
width: 20%;
float: left;
}
}
*overlay*/
.img-container {
position: relative;
width: 100%;
}
.red {
background-color: #B2B2B2;
}
.image {
opacity: 1;
display: block;
width: 100%;
height: auto;
transition: .5s ease;
backface-visibility: hidden;
}
.middle {
transition: .5s ease;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%)
}
.img-container .image {
opacity: 0.3;
}
.img-container .middle {
opacity: 1;
}
.text {
background-color: transparent;
color: white;
font-size: 24px;
padding: 16px 32px;
font-family: 'Archivo Black', sans-serif;
text-align: center;
}
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="Custom.css" type="text/css"/>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Lato|Ubuntu" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Archivo+Black" rel="stylesheet">
<div class="container">
<div class="row">
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="https://introcs.cs.princeton.edu/java/stdlib/mandrill200x200.jpg" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="https://introcs.cs.princeton.edu/java/stdlib/mandrill200x200.jpg" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="img/sample.png" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="https://introcs.cs.princeton.edu/java/stdlib/mandrill200x200.jpg" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="https://introcs.cs.princeton.edu/java/stdlib/mandrill200x200.jpg" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
</div>
<div class="row margin20">
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="https://introcs.cs.princeton.edu/java/stdlib/mandrill200x200.jpg" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="https://introcs.cs.princeton.edu/java/stdlib/mandrill200x200.jpg" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="https://introcs.cs.princeton.edu/java/stdlib/mandrill200x200.jpg" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="https://introcs.cs.princeton.edu/java/stdlib/mandrill200x200.jpg" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
<div class="col-md-15 col-sm-15 col-xs-12">
<div class="img-container red">
<img src="https://introcs.cs.princeton.edu/java/stdlib/mandrill200x200.jpg" alt="Avatar" class="image" style="width:100%">
<div class="middle">
<div class="text">MEN'S APPAREL</div>
</div>
</div>
</div>
</div>
</div>
I want to divide my row in 5 equal parts that is why i used col-md-15 and col-sm-15, it is working well in tablet,mobile,and desktop (if you will remove the col-xs-12 in every tag), however in mobile mode i want the images to be 1 per row that is why i inserted col-xs-12, however when i did that, the rows in tablet and desktop mode became 1 per row and stretched which is i dont want. How to fix this problem?
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="Custom.css" type="text/css"/>
You load custom css before bootstrap css, switch that around.
Edited the example, sry, I meant the other way around. Custom css last, so it overrides the other code.