我現在被卡住了,現在不要如何着手。所以我製作了一個固定高度的Bootstrap旋轉木馬。幻燈片中的圖像應該慢慢下降。我現在遇到的問題是,這在我更大的屏幕上運行良好。但是,當窗口變小時,圖片就會出現問題。目前我將550px的圖片向上移動。所以我可以將高度設置爲100%,但在轉換過程中調整窗口大小時,轉換速度會變慢。Responsive Bootstrap Carousel with movingable images
所以我想也許transform: scale(x,y);
可以幫助,但我不知道如何計算x
和y
。現在我希望,也許有人有一個很棒的想法,可以幫助我。
感謝:]
https://jsfiddle.net/Lq9Lrsft/
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/custom.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<title>Car Mega Bid - Partnerprogramm</title>
</head>
<body>
<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>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<div style="background-image: url(http://lorempixel.com/output/food-q-c-1280-853-1.jpg);" class="slider-size slider-img"></div>
</div>
<div class="item">
<div style="background-image: url(http://lorempixel.com/output/animals-q-c-1280-852-3.jpg);" class="slider-size slider-img"></div>
</div>
</div>
<!-- Left and right controls -->
<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>
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- jQuery Easing plugin -->
<script src="js/jquery.easing.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Custom JavaScript -->
<script src="js/custom.js"></script>
</body>
</html>
CSS
.slider-size {
height: 500px; /* This is the slider height */
}
.slider-img {
background-size: cover;
background-repeat: no-repeat;
background-position: center 0;
}
.slide-img-movedown {
background-position: center 100%;
-webkit-transition: background-position 8s linear;
-moz-transition: background-position 8s linear;
-o-transition: background-position 8s linear;
transition: background-position 8s linear;
}
Java類cript
$(document).ready(function() {
// Timing of sliding
$(".carousel").carousel({
interval: 10000
});
$(this).find('.item.active div').addClass("slide-img-movedown");
});
// Before sliding begins
$('#myCarousel').on('slide.bs.carousel', function(e) {
$prevSlide = $(this).find('.item.active div');
})
// After slide transistion is completed
$('#myCarousel').on('slid.bs.carousel', function(e) {
$prevSlide.removeClass("slide-img-movedown");
$(this).find('.item.active div').addClass("slide-img-movedown");
})
不錯,謝謝。看起來不錯。這是一個很好的起點,我會試着去適應我的項目。 :] Sry爲遲到的響應順便說一句。 – JumbleGee