Flipping image grid with different pictures - html

I am creating a responsive image grid. Currently, there is the same picture in each box but I would like to create a mask so that that image is shown throughout all of the boxes, not repeated in each. Kind of like this: http://ptgmedia.pearsoncmg.com/images/chap3_032133065x/elementLinks/082fig02.jpg
I also would like to create a flipping effect on each box where when it flips over, it would show a completely different picture, just in that one box.
Thanks in advance for your help if applicable.
div.grid {
font-size: 0;
width: 95%;
margin: 30px auto;
font-family: sans-serif;
}
a.grid {
font-size: 16px;
overflow: hidden;
display: inline-block;
margin-bottom: 8px;
width: calc(50% - 4px);
margin-right: 8px;
clip:
}
a.grid:nth-of-type(2n) {
margin-right: 0;
}
#media screen and (min-width: 50em) {
a.grid {
width: calc(25% - 6px);
}
a.grid:nth-of-type(2n) {
margin-right: 8px;
}
a.grid:nth-of-type(4n) {
margin-right: 0;
}
}
a.grid:hover img {
}
figure {
margin: 0;
}
img.grid {
border: none;
max-width: 100%;
height: auto;
display: block;
background: #ccc;
transition: transform .2s ease-in-out;
}
.p a {
display: inline;
font-size: 13px;
margin: 0;
}
.p {
text-align: center;
font-size: 13px;
padding-top: 100px;
}
<div class="grid">
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
<a class="grid" href="#">
<figure>
<img class="grid" src="https://static.pexels.com/photos/7613/pexels-photo.jpg" alt="">
</figure>
</a>
</div>

If I got you right, you're trying to do something like this:
EDIT: Fixed the buggy hover and that the items remain squares.
html, body{
width:100%;
height:100%;
box-sizing:border-box;
margin:0;
padding:0;
}
.grid{
width:calc(60vw + 30px);
display:inline-block;
position:fixed;
background-color:lightgray;
perspective:1000px;
}
.griditem{
display:block;
width:20vw;
margin:5px;
height:20vw;
float:left;
}
.front{
width:100%;
height:100%;
background:#fff url('http://www.popsci.com/sites/popsci.com/files/styles/large_1x_/public/import/2013/images/2013/03/bluemarble_1.jpg?itok=-IIyWZZX') no-repeat;
background-attachment:fixed;
background-position: top left;
background-size:cover;
transform:rotateY(0deg);
transition:.4s ease-in-out;
cursor:pointer;
}
.back{
width:100%;
height:100%;
transform:rotateY(180deg);
background:#fff url('http://www.dentoncorkermarshall.com/wp-content/uploads/2013/12/Asia-Square-06.jpg?x92178') no-repeat;
background-size:cover;
backface-visibility:hidden;
transition:.4s ease-in-out;
position:absolute;
top:0;
z-index:2;
}
.griditem:hover .front{
transform:rotateY(180deg);
transition:.4s ease-in-out;
}
.griditem:hover .back{
transform:rotateY(0deg);
transition:.4s ease-in-out;
}
<div class="grid">
<div class="griditem">
<div class="front">
<div class="back"></div>
</div>
</div>
<div class="griditem">
<div class="front">
<div class="back"></div>
</div>
</div>
<div class="griditem">
<div class="front">
<div class="back"></div>
</div>
</div>
<div class="griditem">
<div class="front">
<div class="back"></div>
</div>
</div>
<div class="griditem">
<div class="front">
<div class="back"></div>
</div>
</div>
<div class="griditem">
<div class="front">
<div class="back"></div>
</div>
</div>
<div class="griditem">
<div class="front">
<div class="back"></div>
</div>
</div>
<div class="griditem">
<div class="front">
<div class="back"></div>
</div>
</div>
<div class="griditem">
<div class="front">
<div class="back"></div>
</div>
</div>
</div>

Related

The pictures below are moving when hovering

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>

Why after the third row the float property does not work correctly? [duplicate]

This question already has answers here:
Floated elements of variable height push siblings down
(3 answers)
What is a clearfix?
(10 answers)
What methods of ‘clearfix’ can I use?
(29 answers)
Closed 2 years ago.
After some rows the css float property have a strange behavior that i couldn't know its reason.
Take into account that I cannot add a div with a "clear" property between the rows because the html will be generated dynamically (php loop).
I think that in order to do that I should create a function in php that determines when to insert a clear div between the rows because sometimes there are 2 images per and other times 3.
But I prefer a CSS solution.
Here is the full code:
.row {
width: 600px;
text-align: center;
margin: 0 auto;
}
.boxes{
box-sizing: border-box;
position: relative;
min-height: 1px;
height: auto;
float: left;
padding-left: 10px;
padding-bottom: 10px;
}
.box1 {
width: 33.33333333333333%;
}
.box2 {
width: 66.66666666666666%;
}
.box-inner {
background-color: grey;
width: 100%;
height: 100%;
}
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}
<html>
<body>
<div class="row">
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box2 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/770/238?random=1" alt="">
</div>
</div>
<div class="box2 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/770/238?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
</div>
</body>
</html>
In your example, you have an image that's slightly shorter than the one before it. That's causing the gap on the following row which clear would normally fix. if you had the same number of elements per row then something like nth-child could be used with clear, but since you said the number of elements per line could change, that wouldn't work. An easy fix is to set a minimum height on your .box-inner class:
.row {
width: 600px;
text-align: center;
margin: 0 auto;
}
.boxes {
box-sizing: border-box;
position: relative;
min-height: 1px;
height: auto;
float: left;
padding-left: 10px;
padding-bottom: 10px;
}
.box1 {
width: 33.33333333333333%;
}
.box2 {
width: 66.66666666666666%;
}
.box-inner {
background-color: grey;
width: 100%;
height: 100%;
min-height: 122px;
}
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}
<div class="row">
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box2 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/770/238?random=1" alt="">
</div>
</div>
<div class="box2 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/770/238?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
<div class="box1 boxes">
<div class="box-inner">
<img class="img-responsive" src="https://picsum.photos/390/244?random=1" alt="">
</div>
</div>
</div>
The easiest solution is to add a fixed height to your container.
.box-inner {
background-color: grey;
width: 100%;
height: 120px;
overflow: hidden;
}
Another addition to the above is to add object-fit: cover to your image to ensure it fills the container space.
.box-inner img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}

Align movement direction elements(previous/next) before/after a relative positioned element (no flexbox)

I'm working on multi-item carousel, and I need to align 2 elements, previous,next - before,after a container that is in position relative;
I need:
Previous to be vertical align in the middle before items
Next to be vertical align in the middle after items
for Next,Previous I want to use in the end an icon font
items using javascript will be moved left-right, so he needs to be relative positioned
I tried to use display:inline-block on items, but doesn't work as expected;
! Can be used floats instead of display: inline-block for class item-container.
I can't use flexbox, because I need to support older browsers.
.carousel {
width: 500px;
overflow: hidden;
position: relative;
white-space: nowrap;
}
.c-carousel__previous,
.c-carousel__next {
display: inline-block;
}
.items {
top: 0px;
left: 0;
position: relative;
display: inline-block;
}
.item-container {
width: 16.66667%;
display: inline-block;
}
<div class="carousel">
<div class="previous">
previous
</div>
<div class="items">
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
</div>
<div class="next">
next
</div>
</div>
Try this
.carousel {
width: 500px;
overflow: hidden;
position: relative;
white-space: nowrap;
}
.previous,
.next {
display: inline-block;
vertical-align: middle;
width: 25px;
}
.items {
top: 0px;
left: 0;
position: relative;
display: inline-block;
vertical-align: middle;
width: 450px;
overflow: hidden;
}
.item-container {
width: 16.66667%;
display: inline-block;
}
<div class="carousel">
<div class="previous">
previous
</div>
<div class="items">
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
</div>
<div class="next">
next
</div>
</div>
and please adjust the width accordingly.
Try vertical-align: middle in .items container with overflow: hidden
body {
margin: 0;
}
.carousel {
width: 500px;
overflow: hidden;
position: relative;
white-space: nowrap;
}
.previous,
.next {
display: inline-block;
}
.items {
display: inline-block;
vertical-align: middle;
overflow: hidden;
}
.item-container {
width: 16.66667%;
margin: 0 5px;
display: inline-block;
}
<div class="carousel">
<div class="previous">previous</div>
<div class="items">
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
</div>
<div class="next">next</div>
</div>
Use display: inline-block on correct classes and give width to item.
Hope this would work:
.carousel {
width: 500px;
overflow: hidden;
position: relative;
white-space: nowrap;
}
.previous,
.next {
display: inline-block;
width: 50px;
vertical-align: top;
}
.items {
top: 0px;
left: 0;
position: relative;
display: inline-block;
width: calc(500px - 100px);
overflow: hidden;
}
.item-container {
width: 16.66667%;
display: inline-block;
}
<div class="carousel">
<div class="previous">
previous
</div>
<div class="items">
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
<div class="item-container">
<a href="">
<img src="http://via.placeholder.com/50x50">
</a>
</div>
</div>
<div class="next">
next
</div>
</div>
The above answers are good, if all the elements are static, but I mentioned that
'items using javascript will be moved left-right, so it needs to be
relative positioned';
This movement of the 'items' class created multiple issues, in all the above cases(like 'hiding' next/previous, overflow hidding content that should be vissible;
So, the solution I found:
remove overflow: hidden from carousel
add a new container for items, items-container and use overflow: hidden on this one
position next,previous absolute

Overlay with words across multiple images

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>

Get the images straight to the div width

I have a image gallery which is not straighting/fullfilling the full width in a row
html
<div class="col-md-6">
<figure class="gallery">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
<img src="images/blog_1.png" alt="img">
</figure>
</div>
css
.gallery{
display:table;
}
.gallery img{
display: inline-block;
padding: 2px;
background: transparent;
}
display:table-cell is also not working . There is 6 images here
.gallery{
display:table;
white-space: nowrap;
}
.gallery img{
display: inline-block;
padding: 2px;
background: transparent;
}
<div class="col-md-6">
<figure class="gallery">
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
<img src="http://placehold.it/100x100" alt="img" />
</figure>
</div>
From what I understood (since you have not mentioned the image size.)
.gallery{
}
.gallery > div{
padding:2px;
}
.gallery img{
background: transparent;
width:100%;
}
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="col-md-12">
<div class="gallery row">
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
<div class="col-xs-2">
<img src="http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg" alt="img"/>
</div>
</div>
</div>
Add Below css
.gallery{
display:table;
margin:0;
}
DEMO