html - How to get Bootstrap Carousel to fit 100% to screen? -
i wondering how carousel in bootstrap's carousel example fit 100% screen, opposed way it's displaying allows blank circular images included in main landing page when loaded.
here's simple illustration of i'm trying working.
page source (relevant bit):
<!-- carousel ================================================== --> <div id="mycarousel" class="carousel slide" data-ride="carousel"> <!-- indicators --> <ol class="carousel-indicators"> <li data-target="#mycarousel" data-slide-to="0" class="active"></li> <li data-target="#mycarousel" data-slide-to="1"></li> <li data-target="#mycarousel" data-slide-to="2"></li> </ol> <div class="carousel-inner" role="listbox"> <div class="item active"> <img class="first-slide" src="data:image/gif;base64,r0lgodlhaqabaiaaahd3dwaaach5baaaaaaalaaaaaabaaeaaaicraeaow==" alt="first slide"> <div class="container"> <div class="carousel-caption"> <h1>example headline.</h1> <p>note: if you're viewing page via <code>file://</code> url, "next" , "previous" glyphicon buttons on left , right might not load/display due web browser security rules.</p> <p><a class="btn btn-lg btn-primary" href="#" role="button">sign today</a></p> </div> </div> </div> <div class="item"> <img class="second-slide" src="data:image/gif;base64,r0lgodlhaqabaiaaahd3dwaaach5baaaaaaalaaaaaabaaeaaaicraeaow==" alt="second slide"> <div class="container"> <div class="carousel-caption"> <h1>another example headline.</h1> <p>cras justo odio, dapibus ac facilisis in, egestas eget quam. donec id elit non mi porta gravida @ eget metus. nullam id dolor id nibh ultricies vehicula ut id elit.</p> <p><a class="btn btn-lg btn-primary" href="#" role="button">learn more</a></p> </div> </div> </div> <div class="item"> <img class="third-slide" src="data:image/gif;base64,r0lgodlhaqabaiaaahd3dwaaach5baaaaaaalaaaaaabaaeaaaicraeaow==" alt="third slide"> <div class="container"> <div class="carousel-caption"> <h1>one more measure.</h1> <p>cras justo odio, dapibus ac facilisis in, egestas eget quam. donec id elit non mi porta gravida @ eget metus. nullam id dolor id nibh ultricies vehicula ut id elit.</p> <p><a class="btn btn-lg btn-primary" href="#" role="button">browse gallery</a></p> </div> </div> </div> </div> <a class="left carousel-control" href="#mycarousel" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">previous</span> </a> <a class="right carousel-control" href="#mycarousel" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">next</span> </a> </div><!-- /.carousel -->
carousel.css (relevant bit):
/* customize carousel -------------------------------------------------- */ /* carousel base class */ .carousel { height: 500px; margin-bottom: 60px; } /* since positioning image, need out caption */ .carousel-caption { z-index: 10; } /* declare heights because of positioning of img element */ .carousel .item { height: 500px; background-color: #777; } .carousel-inner > .item > img { position: absolute; top: 0; left: 0; min-width: 100%; height: 500px; }
i know task @ hand pretty simple, , admit have tried tinkering around carousel.css file past hour or (changing various height position, z-index, etc. values), can't seem resizing work without majorly screwing things up. more specifically, tried adding
you have fixed height carousel , carousel items. of size.
try this
html,body{ height:100%; } .carousel,.item,.active{ height:100%; } .carousel-inner{ height:100%; }
even after changing won't work can replace carousel 1 here demo
also via jquery can first windows total height , set height of carousel wrapper , other elements accordingly.
$(document).ready(function(){ var height = $(window).height(); //getting windows height jquery('#mycarousel').css('height',height+'px'); //and setting height of carousel });
Comments
Post a Comment