Ich habe ein Bootstrap Karussell mit einer festen Höhe. Hier ist die CSS:Bootstrap Karussell mit fester Höhe: Bild in der Mitte horizontal oder vertikal basierend auf Bildmaße
.carousel-custom .carousel-outer {
position: relative;
}
@media(min-width: 992px){
.carousel-custom {
margin-top: 20px;
.carousel-inner {
height: auto;
.item {
height:500px;
line-height:300px;
}
}
}
}
@media(max-width: 991px){
.carousel-custom {
margin-top: 20px;
.carousel-inner {
height: auto;
.item {
height:300px;
line-height:300px;
text-align:center;
}
}
}
}
Und hier ist mein Markup:
<div id="carousel-custom-1188" class="carousel slide carousel-custom" data-ride="carousel">
<div class="carousel-outer">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459261752/w8edcuvz1yl3uc4g4o34.jpg" alt="Jinallzupvfazqqr67nd">
<div class="carousel-caption"></div>
</div>
<div class="item">
<img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459175684/w4ueot8o49dh2fyulv0x.jpg" alt="K1yov5hpur8mgsb9r15p">
<div class="carousel-caption"></div>
</div>
<div class="item">
<img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459178926/fwlmuroj2wlz7czrsha0.jpg" alt="Lqfandhmutdkppjrl932">
<div class="carousel-caption"></div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-custom-1188" 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="#carousel-custom-1188" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!-- Indicators -->
<ol class="carousel-indicators mCustomScrollbar">
<li data-target="#carousel-custom-1188" data-slide-to="0" class="active">
<img style="height:50px; width: 50px;" class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459268139/jinallzupvfazqqr67nd.png" alt="Jinallzupvfazqqr67nd">
</li>
<li data-target="#carousel-custom-1188" data-slide-to="1" class="">
<img style="height:50px; width: 50px;" class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459268146/k1yov5hpur8mgsb9r15p.png" alt="K1yov5hpur8mgsb9r15p">
</li>
<li data-target="#carousel-custom-1188" data-slide-to="2" class="">
<img style="height:50px; width: 50px;" class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459268157/lqfandhmutdkppjrl932.png" alt="Lqfandhmutdkppjrl932">
</li>
</ol>
</div>
</div>
Das Problem ist, dass ich Bilder, die sehr breit sind, andere sehr schmal und hoch, und andere mit einer guten Ration Höhe/Breite im selben Karussell.
Ich möchte die Wide Bilder vertikal zentriert (mit einer Breite von 100%), hohe Bilder horizontal (mit einer Höhe von 100%) und "normale" Bilder (mit einem angemessenen Verhältnis Höhe/Breite) Füllen Sie das ganze Karussell.
Hier ist, was ich versuche zu tun (erstes Bild ist ein Beispiel mit einem sehr breiten Bild, zweites Bild mit einem sehr hohen, und das letzte Bild hat ein "anständiges" Verhältnis).
Wie kann ich das erreichen? Ich habe versucht Make Bootstrap's Carousel both center AND responsive? und andere Tricks auf Google gefunden, aber niemand hat dies getan.
sehen Es ist schwer, Ihnen zu helfen, da Sie eine nicht-proccessed teilen Code aus einer Vorlage. Es ist besser, wenn Sie den gerenderten HTML-Code teilen, und vielleicht gibt es eine einfache Lösung. Wenn ich Ihre Frage gut verstehe, müssen Sie nur die Mitte (vertikal und horizontal) der Bilder im Schieberegler perfekt ausrichten. –
@ MarcosPérezGude danke für deine Antwort, ich habe den Beitrag mit dem gerenderten HTML bearbeitet (für ein Karussell mit 3 Bildern). Was ich brauche, ist das Bild perfekt zu zentrieren, aber ohne es zu strecken, wenn es zu breit oder zu schmal ist, und ohne einen Teil davon versteckt zu haben (Ich habe viele Lösungen ausprobiert, wo ein Teil des Bildes versteckt war) –