js滑动图像(旋转木马)变得无形

时间:2016-11-16 00:03:58

标签: javascript html css

我正试图在我的页面“http://www.donnaliartist.com/testpage.php”上制作旋转木马(或滑动图像,不知道如何调用它) 但是图像看不见了,我不明白为什么。

这是我的HTML代码

<div id="slideImg" class="row centered moveup img">
                    <div class="slideMain">
                        <ul class="slide1">
                            <li><img src="assets/img/donna-megan.jpg" width="1151px" hspace="15" class="img-responsive"></li>
                            <li><img src="assets/img/donna-charcoal.jpg" width="1151px" hspace="15" class="img-responsive"></li>
                        </ul>
                    </div>
                </div>

js script

<script type="text/javascript">
    $(document).ready(function(){
      $("#slideImg").rotate({
        speed:10,
        width:"900px",
        slide1:".slide1"
      });
    });
  </script>

和我页面底部的js脚本

<script src="assets/js/slides.min.jquery.js"></script>
<script src="assets/js/jquery.rotate.js"></script>

3 个答案:

答案 0 :(得分:2)

您无法看到图片,因为#slideImg上的高度为0.但我不确定这一行:$("#slideImg").rotate({...。你为什么在这里使用rotate?这应该是$("#slideImg").slidesjs({...吗?更改后,您可能仍需要将高度选项传递给slidesjs。

答案 1 :(得分:1)

看起来您的代码正在旋转元素,例如45度。您想要更改显示的幻灯片。有很多方法可以做到这一点。就个人而言,我喜欢使用Bootstrap3,请参阅以下内容

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
width: 70%;
margin: auto;
}
</style>
</head>
<body>
<div class="container">
<br>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<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>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="a.jpg" alt="a" width="460" height="345">
</div>
<div class="item">
<img src="b.jpg" alt="b" width="460" height="345">
</div>
<div class="item">
<img src="c.jpg" alt="c" width="460" height="345">
</div>
<div class="item">
<img src="d.jpg" alt="d" width="460" height="345">
</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>
</div>
</body>
</html>

答案 2 :(得分:1)

像这样的东西,在页面底部你必须点击prevous或next或者你必须添加一个计时器

$('#slides').slidesjs({
  width: 100,
  height: 100
});
 
#slides {
  display: none
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/nathansearles/Slides/SlidesJS-3/source/jquery.slides.min.js"></script>




<div id="slides">
  <img src="http://www.donnaliartist.com/images/751425.jpg">
  <img src="http://www.donnaliartist.com/images/201867.jpg">
</div>