2013-05-03 14 views
38

मैं बूटस्ट्रैप हिंडोला में छवि प्राप्त करने के लिए पूर्ण स्क्रीन को दिखाने के लिए कोशिश कर रहा हूँ, लेकिन नहीं यह पता लगाने के लिए सक्षम किया गया है, मैं कुछ समय के लिए इस पर काम कर रहा है और पूरी तरह से अटक कर रहा हूँ। अभी मैं सिर्फ एक छवि है, लेकिन मैं और अधिक जोड़ देगा एक बार यह काम करता है ...बूटस्ट्रैप Carousel पूर्ण स्क्रीन

<!DOCTYPE html> 

<html lang="en"> 
    <head> 
    <meta charset="utf-8"> 
    <title>Carousel Template &middot; Bootstrap</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <meta name="description" content=""> 
    <meta name="author" content=""> 

    <!-- Le styles --> 
    <link href="../assets/css/bootstrap.css" rel="stylesheet"> 
    <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> 
    <style> 

    /* GLOBAL STYLES 
    -------------------------------------------------- */ 
    /* Padding below the footer and lighter body text */ 

    body { 
     color: #5a5a5a; 
     height: 100%; 
     width: 100%; 
     min-height: 100%; 
    } 



    /* CUSTOMIZE THE NAVBAR 
    -------------------------------------------------- */ 

    /* Special class on .container surrounding .navbar, used for positioning it into place. */ 
    .navbar-wrapper { 
     position: absolute; 
     top: 0; 
     left: 0; 
     right: 0; 
     z-index: 10; 
     margin-top: 20px; 
    } 
    .navbar-wrapper .navbar { 

    } 

    /* Remove border and change up box shadow for more contrast */ 
    .navbar .navbar-inner { 
     border: 0; 
     -webkit-box-shadow: 0 2px 10px rgba(0,0,0,.25); 
     -moz-box-shadow: 0 2px 10px rgba(0,0,0,.25); 
       box-shadow: 0 2px 10px rgba(0,0,0,.25); 
    } 

    /* Downsize the brand/project name a bit */ 
    .navbar .brand { 
     padding: 14px 20px 16px; /* Increase vertical padding to match navbar links */ 
     font-size: 16px; 
     font-weight: bold; 
     text-shadow: 0 -1px 0 rgba(0,0,0,.5); 
    } 

    /* Navbar links: increase padding for taller navbar */ 
    .navbar .nav > li > a { 
     padding: 15px 20px; 
    } 

    /* Offset the responsive button for proper vertical alignment */ 
    .navbar .btn-navbar { 
     margin-top: 10px; 
    } 



    /* CUSTOMIZE THE CAROUSEL 
    -------------------------------------------------- */ 

    /* Carousel base class */ 
    .carousel { 
     margin-bottom: 0px; 
    } 

    .carousel .container { 
     position: relative; 
     z-index: 9; 
    } 

    .carousel .item { 
     height: 100%; 
    } 

    .carousel-inner { 
     overflow:hidden; 
     width: 100%; 
     min-height: 100%; 
     position:relative; 
    } 

    .carousel img { 
     position: absolute; 
     top: 0; 
     left: 0; 
     min-width: 100%; 
     min-height: 100%; 
    } 

    .carousel-caption { 
     background-color: transparent; 
     position: static; 
     max-width: 550px; 
     padding: 0 20px; 
     margin-top: 200px; 
    } 
    .carousel-caption h1, 
    .carousel-caption .lead { 
     margin: 0; 
     line-height: 1.25; 
     color: #fff; 
     text-shadow: 0 1px 1px rgba(0,0,0,.4); 
    } 
    .carousel-caption .btn { 
     margin-top: 10px; 
    } 


    /* RESPONSIVE CSS 
    -------------------------------------------------- */ 

    @media (max-width: 979px) { 

     .container.navbar-wrapper { 
     margin-bottom: 0; 
     width: auto; 
     } 
     .navbar-inner { 
     border-radius: 0; 
     margin: -20px 0; 
     } 

     .carousel img { 
     width: auto; 
     height: 500px; 
     } 

     .featurette { 
     height: auto; 
     padding: 0; 
     } 
     .featurette-image.pull-left, 
     .featurette-image.pull-right { 
     display: block; 
     float: none; 
     max-width: 40%; 
     margin: 0 auto 20px; 
     } 
    } 


    @media (max-width: 767px) { 

     .navbar-inner { 
     margin: -20px; 
     } 

     .carousel { 
     margin-left: -20px; 
     margin-right: -20px; 
     } 
     .carousel img { 
     height: 300px; 
     } 
     .carousel-caption { 
     width: 65%; 
     padding: 0 70px; 
     margin-top: 100px; 
     } 
     .carousel-caption h1 { 
     font-size: 30px; 
     } 
     .carousel-caption .lead, 
     .carousel-caption .btn { 
     font-size: 18px; 
     } 

     .marketing .span4 + .span4 { 
     margin-top: 40px; 
     } 

     .featurette-heading { 
     font-size: 30px; 
     } 
     .featurette .lead { 
     font-size: 18px; 
     line-height: 1.5; 
     } 

    } 
    </style> 

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> 
    <!--[if lt IE 9]> 
     <script src="../assets/js/html5shiv.js"></script> 
    <![endif]--> 

    <!-- Fav and touch icons --> 
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png"> 
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png"> 
     <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png"> 
        <link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png"> 
            <link rel="shortcut icon" href="../assets/ico/favicon.png"> 
    </head> 

    <body> 



    <!-- NAVBAR 
    ================================================== --> 
    <div class="navbar-wrapper"> 
     <!-- Wrap the .navbar in .container to center it within the absolutely positioned parent. --> 
     <div class="container"> 

     <div class="navbar navbar-inverse"> 
      <div class="navbar-inner"> 
      <!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. --> 
      <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> 
       <span class="icon-bar"></span> 
       <span class="icon-bar"></span> 
       <span class="icon-bar"></span> 
      </button> 
      <a class="brand" href="#">Treyca</a> 
      <!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. --> 
      <div class="nav-collapse collapse"> 
       <ul class="nav"> 
       <li class="active"><a href="#">Home</a></li> 
       <li><a href="#about">About</a></li> 
       <li><a href="fluid.html">Beta</a></li> 
       <li><a href="#contact">Contact</a></li> 
       <!-- Read about Bootstrap dropdowns at http://twitter.github.com/bootstrap/javascript.html#dropdowns --> 
       <li class="dropdown"> 
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a> 
        <ul class="dropdown-menu"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider"></li> 
        <li class="nav-header">Nav header</li> 
        <li><a href="#">Separated link</a></li> 
        <li><a href="#">One more separated link</a></li> 
        </ul> 
       </li> 
       </ul> 
      </div><!--/.nav-collapse --> 
      </div><!-- /.navbar-inner --> 
     </div><!-- /.navbar --> 

     </div> <!-- /.container --> 
    </div><!-- /.navbar-wrapper --> 



    <!-- Carousel 
    ================================================== --> 
    <div id="myCarousel" class="carousel slide"> 
     <div class="carousel-inner"> 
     <div class="item active"> 
      <img src="../assets/img/examples/Bar-1.jpg" alt=""> 
      <div class="container"> 
      <div class="carousel-caption"> 
       <h1>Example headline.</h1> 
       <p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> 
       <a class="btn btn-large btn-primary" href="#">Sign up today</a> 
      </div> 
      </div> 
     </div> 
     </div> 
     <!-- FOOTER --> 
     <footer> 
     <p>&copy; 2013 Company, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p> 
     </footer> 
    </div><!-- /.carousel --> 

    <!-- Le javascript 
    ================================================== --> 
    <!-- Placed at the end of the document so the pages load faster --> 
    <script src="../assets/js/jquery.js"></script> 
    <script src="../assets/js/bootstrap-transition.js"></script> 
    <script src="../assets/js/bootstrap-alert.js"></script> 
    <script src="../assets/js/bootstrap-modal.js"></script> 
    <script src="../assets/js/bootstrap-dropdown.js"></script> 
    <script src="../assets/js/bootstrap-scrollspy.js"></script> 
    <script src="../assets/js/bootstrap-tab.js"></script> 
    <script src="../assets/js/bootstrap-tooltip.js"></script> 
    <script src="../assets/js/bootstrap-popover.js"></script> 
    <script src="../assets/js/bootstrap-button.js"></script> 
    <script src="../assets/js/bootstrap-collapse.js"></script> 
    <script src="../assets/js/bootstrap-carousel.js"></script> 
    <script src="../assets/js/bootstrap-typeahead.js"></script> 
    <script> 
     !function ($) { 
     $(function(){ 
      // carousel demo 
      $('#myCarousel').carousel() 
     }) 
     }(window.jQuery) 
    </script> 
    <script src="../assets/js/holder/holder.js"></script> 

    <style> 
     body { 
       background-color: black; 
       color: #FFFFFF; 
      } 
    </style> 
    </body> 
</html> 

उत्तर

55

यकीन हिंडोला आइटम अंदर img ऊंचाई पर सेट है और 100% चौड़ाई। तुम भी हिंडोला और .item कंटेनर (एचटीएमएल, शरीर) 100% कर रहे हैं के किसी भी सुनिश्चित करने के लिए है ...

html,body{height:100%;} 
.carousel,.item,.active{height:100%;} 
.carousel-inner{height:100%;} 

Boostrap Full Screen Carousel Demo

यहाँ बूटस्ट्रैप 3.x के लिए एक उदाहरण है: http://www.codeply.com/go/2tVXo3mAtV

+0

आपके पृष्ठ 404 है/500 – Blowsie

+0

http://bootply.com/59900 - मेरे लिए काम करता है – ZimSystem

13

मैं लगभग हर बूटस्ट्रैप परियोजना में पूरी चौड़ाई स्लाइडर का उपयोग करें। यहाँ यह करने के लिए अपने दृष्टिकोण है:

1) (एक कस्टम पूरी चौड़ाई कंटेनर में हिंडोला लपेटें किसी भी .container वर्ग के बाहर)
2) छवि स्लाइड की चौड़ाई और 100%
3 करने के लिए अपने कंटेनर सेट) सेट स्लाइडर के रूप में वांछित की ऊंचाई

और यह इस प्रकार है:

<section class="block"> 
    <div id="myCarousel" class="carousel slide"> 
     <div class="carousel-inner"> 
      <div class="active item"> 
       <img src="http://lorempixel.com/1024/750" alt="Slide1" /> 
      </div> 
      <div class="item"> 
       <img src="http://lorempixel.com/1024/750" alt="Slide2" /> 
      </div> 
      <div class="item"> 
       <img src="http://lorempixel.com/1024/750" alt="Slide3" /> 
      </div> 
     </div> 
     <a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a> 
     <a class="carousel-control right" href="#myCarousel" data-slide="next">›</a> 
    </div> 
</section> 

और सीएसएस इस प्रकार दिखाई देगा:

.carousel .item { 
    width: 100%; /*slider width*/ 
    max-height: 600px; /*slider height*/ 
} 
.carousel .item img { 
    width: 100%; /*img width*/ 
} 
/*full width container*/ 
@media (max-width: 767px) { 
    .block { 
     margin-left: -20px; 
     margin-right: -20px; 
    } 
} 
0

मैं एक ही समस्या थी रहा हूँ, और मैं ऊपर जवाब के साथ की कोशिश की, लेकिन मैं कुछ और पतली चाहता था, तो मैं opsions एक एक करके बदलने की कोशिश की है, और पता चलता है कि हम सिर्फ

.carousel { 
    height: 100%; 
} 
जोड़ने की जरूरत
+1

कृपया बताएं कि आप इसे देने के बजाए अपने उत्तर पर कैसे पहुंचे ताकि अन्य इससे सीख सकें। – ArtB

+0

मेरे लिए काम करें !, लेकिन मुझे लगता है कि आपको छवियों के आयामों को भी बदलना चाहिए, .. मेरे लिए मैं सभी छवियों को 1280: 720 के पैमाने में बदलता हूं (या फसल) – Windo

1

मैं startbootstrap.com पर एक जवाब मिल गया। इस कोड का प्रयास करें:

सीएसएस

html, 
body { 
    height: 100%; 
} 

.carousel, 
.item, 
.active { 
    height: 100%; 
} 


.carousel-inner { 
    height: 100%; 
} 

/* Background images are set within the HTML using inline CSS, not here */ 

.fill { 
    width: 100%; 
    height: 100%; 
    background-position: center; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    background-size: cover; 
    -o-background-size: cover; 
} 

footer { 
    margin: 50px 0; 
} 

एचटीएमएल

<div class="carousel-inner"> 
     <div class="item active"> 
      <!-- Set the first background image using inline CSS below. --> 
      <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide One');"></div> 
      <div class="carousel-caption"> 
       <h2>Caption 1</h2> 
      </div> 
     </div> 
     <div class="item"> 
      <!-- Set the second background image using inline CSS below. --> 
      <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide Two');"></div> 
      <div class="carousel-caption"> 
       <h2>Caption 2</h2> 
      </div> 
     </div> 
     <div class="item"> 
      <!-- Set the third background image using inline CSS below. --> 
      <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide Three');"></div> 
      <div class="carousel-caption"> 
       <h2>Caption 3</h2> 
      </div> 
     </div> 
    </div> 

Source

0

इस तरह मैंने किया है। यह स्लाइड शो में छवियों को पूर्ण स्क्रीन लेता है यदि यह पहलू अनुपात की अनुमति देता है, अन्यथा इसे स्केल करता है।

.carousel { 
    height: 100vh; 
    width: 100%; 
    overflow:hidden; 
} 
.carousel .carousel-inner { 
    height:100%;  
} 

एक पूर्ण स्क्रीन स्लाइड शो मिल allways करने के लिए, कोई फर्क नहीं पड़ता स्क्रीन पहलू अनुपात, आप भी वस्तु फिट का उपयोग कर सकते हैं: (आईई या एज में नहीं करता काम)

.carousel .carousel-inner img { 
    display:block; 
    object-fit: cover; 
} 
संबंधित मुद्दे