css - Min height for slideshow not working -
my slideshow on top of page has width:100%
, height:400px
css attributes.
but want make responsive web page , make slideshow height variable according width of page.
i have tried using min-height
doesn't work.
i tried putting container's height
on 400px
, image height on auto, solves problem partly slideshow's height changes responsively container stays on 400px
makes empty space between slider , menu bar.
do have ideas?
my css following:
.container { padding:0px; margin:0px; position:relative; padding:0; height:400px; } .img { position:absolute; left:0; top:0; width:100%; height:400px; min-height:auto; }
you need javascript adapt container height absolute element in it.
you can see result on this fiddle , call function once change height @ window loading, use $(window).resize(changeheight);
change everytime window resize
$(function() { $('.fadein img:gt(0)').hide(); setinterval(function() { $('.fadein :first-child').fadeout().next('img').fadein().end().appendto('.fadein'); }, 3000); }); function changeheight() { var biggestheight = "0"; // loop through elements children find & set biggest height $(".fadein *").each(function() { // if elements height bigger biggestheight if ($(this).height() > biggestheight) { // set biggestheight height biggestheight = $(this).height(); } }); // set container height $(".fadein").height(biggestheight); } changeheight(); $(window).resize(changeheight);
.fadein { padding: 0px; margin: 0px; position: relative; padding: 0; } .fadein img { position: absolute; left: 0; top: 0; width: 100%; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <div class="fadein"> <img src="http://i.imgur.com/fglgf6m.png" align="middle"> <img src="http://i.imgur.com/wpo9fhr.jpg" align="middle"> <img src="http://i.imgur.com/ihius1k.png" align="middle"> </div>i'm text
Comments
Post a Comment