JQuery and CSS with position absolute, height 100% not working in IE11 and Firefox -
i building "view of our products" section new website. when image of product hovered over, should fade image amd slide title of image on top.
i have created jsfiddle working want, , works in chrome, , safari, in ie11 , firefox renders unexpected results.
here html:
<body> <div class="outersqrproducts"> <div class="sqrproductsimage"> <a href="#"> <img src="http://www.avenir-accessories.co.uk/media/4367/beewi-fiat-500-white.jpg"/> </a> </div> <div class="overlay"></div> <div class="ic_caption" id="caption1"> <h2 class="centertext">title</h2> </div> </div> <div class="outersqrproducts"> <div class="sqrproductsimage"> <a href="#"> <img src="http://www.avenir-accessories.co.uk/media/4367/beewi-fiat-500-white.jpg"/> </a> </div> <div class="overlay"></div> <div class="ic_caption"> <h2 class="centertext">title</h2> </div> </div> <body>
here css:
body { background-color: #0097f0; } .centertext { text-align: center; } .outersqrproducts { display: table-cell; vertical-align: middle; height: 234px; width: 234px; background-color: #fff; position: relative; } .sqrproductsimage { display: inline-block; } .sqrproductsimage img { max-height: 234px; max-width: 234px; } .overlay, .ic_caption { position: absolute; left: 0; width: 100%; display: none; } .overlay { background-color: rgba(0, 151, 240, 0.5); height: 100%; top: 0; } .ic_caption { background-color: rgba(0, 151, 240, 0.8); height: 50%; bottom: 0; }
here jquery:
$(document).ready(function () { var div = $('.outersqrproducts'); var overlay = $('.overlay'); var title = $('.ic_caption'); var speed = 500; div.each(function (i) { $(this).attr('id', 'image' + i); var divid = $(this).attr('id'); $('#' + divid).hover(function () { // make background opaque $('#' + divid).find('.overlay').fadein(speed); // slide down title $('#' + divid).find('.ic_caption').slidedown(speed); }, function () { $('#' + divid).find('.ic_caption').slideup(speed); $('#' + divid).find('.overlay').fadeout(speed); }); }); });
here fiddle. http://jsfiddle.net/afg9k/
in ie11, doesn't apply full height of overlay div, no not of image faded out.
in firefox, it's trying fade out , slide title space around div image in it, rather in div (very bizarre!).
have done stupid?
any appreciated.n
the culprit display: table-cell;
in .outersqrproducts
. because of this bug in firefox, relative positioning on elements table-cell display not work.
floating product containers instead, using float: left;
make overlay show intended.
Comments
Post a Comment