A snippet that will centre an image within a container. The image also has a hover and background element ‘on’ the image.
Markup:
CSS: body {
background: #FAFAFA;
}
.cell-wrapper {
display: table;
}
/* Cell */.thumb-wrapper {
display: table-cell;
text-align: center;
vertical-align: middle;
background: #EEEEEE;
width: 139px;
height: 182px;
}
.thumb {
display: inline-block;
position: relative;
}
img {
position: relative;
z-index: 1;
border: 1px solid;
display: block;
}
/*Background*/.thumb:after {
content: '';
width: 100%;
height: 100%;
background: #FFF;
display: block;
position: absolute;
top: 0;
left: 0;
-webkit-box-shadow: 2px 2px 2px 0px #898989;
-moz-box-shadow: 2px 2px 2px 0px #898989;
box-shadow: 2px 2px 2px 0px #898989;
}
/* Offset background for paging effect */.thumb.multi:after {
content: '';
margin-left: 2px;
margin-top: 2px;
}
/* Hover */.thumb.selectable:before {
content: "";
opacity: 0;
width: 100%;
height: 100%;
background: black;
display: block;
position: absolute;
cursor: pointer;
z-index: 2;
}
.thumb.selectable:hover:before {
opacity: 0.2;
}