Ich habe Bootstrap-Karussell und Karussell von img hat data-mobil
und data-table
Attribut und wenn ich das Fenster für Tablet mein img src Wert die Größe wurde mit data-table
src chancing oder wenn ich die Größe des Fensters für mobile mein img src hat Breite data-mobil
src..it's okey so weit..aber zur gleichen Zeit, wenn data-mobil
oder data-tablet
ist undefiniert ist ich meine, ist leer, als es anzuzeigen: keine; aber mein Display nimmt keinen Platz warum?Bootstrap-Karussell Bild, das Display keine div Aufnahmeraum ist
click to see live example - die Größe Fenster für Tablet-Version
function makeResize() {
var imageSrc = $(".main-carousel img");
if ($(window).width() <= 768 && $(window).width() > 480) {
$(imageSrc).each(function(key, value) {
if ($(value).data('tablet') == undefined)
$(value).parent(".item").hide();
else {
$(value).attr('src', $(value).data('tablet'));
$(value).parent(".item").show();
}
});
} else if ($(window).width() <= 480) {
$(imageSrc).each(function(key, value) {
if ($(value).data('mobil') == undefined) {
$(value).parent(".item").hide();
} else {
$(value).attr('src', $(value).data('mobil'));
$(value).parent(".item").show();
}
});
} else {
$(imageSrc).each(function(key, value) {
$(value).attr('src', $(value).data('src'));
$(value).show();
});
}
}
$(document).ready(function(){
$(window).resize(function(){
makeResize();
});
makeResize();
});
.main-carousel{
width:1000px;
}
.main-carousel img{
width:100%;
}
<html lang="en">
<head>
<meta charset="UTF-8" /><link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<body>
<div id="homepage-carousel" class="carousel carousel-fade slide main-carousel" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#homepage-carousel" data-slide-to="0" class="active"></li>
<li data-target="#homepage-carousel" data-slide-to="1"></li>
<li data-target="#homepage-carousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://cdn.anitur.com.tr/resimler/normal/2017-02/banner_Hn3kjP6eM7ltkZzATMMkanitur-enguzel-anilar-manset-banner-2017-6subat.jpg" data-mobil="http://www.anitur.com.tr/blog/wp-content/uploads/2016/06/Karadeniz24-372x221.jpg">
</div>
<div class="item">
<img src="http://cdn.anitur.com.tr/resimler/normal/2016-12/banner_r7SIBGm1BaKCNMsZojfNtermal-bolgeler.jpg" data-tablet="http://www.anitur.com.tr/blog/wp-content/uploads/2016/03/Silversea-cruise-1024x657.jpg" data-mobil="http://www.anitur.com.tr/blog/wp-content/uploads/2016/06/Karadeniz24-372x221.jpg">
</div>
<div class="item">
<img src="http://cdn.anitur.com.tr/resimler/normal/2017-01/banner_PYo0aKYQiz6VN3XF1rTGunknown-2.jpeg" data-tablet="http://www.anitur.com.tr/blog/wp-content/uploads/2016/03/Silversea-cruise-1024x657.jpg" data-mobil="http://www.anitur.com.tr/blog/wp-content/uploads/2016/06/Karadeniz24-372x221.jpg">
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
ich glaube, das Problem ist da Karussell für alle div.item Element überprüfen und hinzufügen/entfernen Klasse aktiv. Wann immer die aktive Klasse auf dem Display ohne Div angewendet wird, sehen Sie ein graues Div auf Ihrem Bildschirm. – Deep
Gibt es irgendeine Funktion für hinzufügen/entfernen wie verstecken/anzeigen? –