Revision: 67118
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 14, 2014 14:30 by brontus
Initial Code
Markup: <div class="cell-wrapper"> <div class="thumb-wrapper"> <div class="thumb selectable multi"> <img src="http://lorempixel.com/60/143"></img> </div> </div> </div> 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; }
Initial URL
http://jsfiddle.net/brontus/jpn1dy2f/3/
Initial Description
A snippet that will centre an image within a container. The image also has a hover and background element 'on' the image.
Initial Title
Center A Resizeable Image Vertically And Horizontally In A Container With Hover And Background
Initial Tags
image
Initial Language
CSS