html - Height auto doesn't work even with clearfix -
probably not first time see question... can't solve problem.
here live version http://jsfiddle.net/lndeh/
if change height .projectwrap
, see trying achieve. have tried add clearfix etc.
html
<div class="projectwrap"> <img src="http://www.vectortemplates.com/raster/superman-logo-012.png"> <div class="inner"><a href=""><span>sometext</span></a></div> </div> <div class="projectwrap"> <img src="http://www.vectortemplates.com/raster/superman-logo-012.png"> <div class="inner"><a href=""><span>some text</span></a></div> </div> <div class="projectwrap"> <img src="http://www.vectortemplates.com/raster/superman-logo-012.png"> <div class="inner"><a href=""><span>some text</span></a></div> </div>
css
.projectwrap { position: relative; width: 28%; height:auto; float:left; } .projectwrap img { position: absolute; width: 100%; } .inner { width: 100%; height: 100%; background-image: url(http://goodlogo.com/images/logos/batman_logo_2574.gif); background-size: cover; position:absolute; z-index: 11; opacity: 0; -webkit-transition: opacity 400ms linear; -o-transition: opacity 400ms linear; -moz-transition: opacity 400ms linear; transition: opacity 400ms linear; } .inner { float:left; text-align: center; display:table; width: 100%; height:100%; } .inner span { display: table-cell; vertical-align: middle; width:100%; height:100%; color:#fff; text-align: center; text-transform: uppercase; } .inner:hover { opacity: 1; -webkit-transition: opacity 400ms linear; -o-transition: opacity 400ms linear; -moz-transition: opacity 400ms linear; transition: opacity 400ms linear; }
since containers floated , contain absolutely positioned images, have no height , float on each other.
if want 3 logos appear, change css images position:relative
.projectwrap img { position: relative; width: 100%; }
edit:
another method, if need use position:absolute
on images:
set minimum height .projectwrap
divs don't collapse 0 height.
then float expected.
.projectwrap { position: relative; width:28%; float:left; min-height:5px;height:auto!important;height:5px; }
edit:
for additional 3 (hidden) images, have changed using background image using same 100% width method used superman logos. placed links on image positioning them absolutely.
.inner { position:relative; width: 100%; ... } .inner { position:absolute; ... }
edit:
i think see you're going for.
switched using background-image
on .inner
using <img />
, kept elements positioned absolutely. work better?
Comments
Post a Comment