首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Html/CSS/Javascript翻转图像功能不起作用

Html/CSS/Javascript翻转图像功能不起作用
EN

Stack Overflow用户
提问于 2013-09-09 15:44:18
回答 1查看 1.1K关注 0票数 0

我必须翻转我的项目中的图像,并使用与css相结合的功能来实现它。当它被翻转时,当再次翻转到原来的div时,它会显示另一个div。但是当我点击的时候什么也不会发生。所以还是有些地方不对劲,但不知道是什么。

Javascript:

代码语言:javascript
复制
<script type="text/javascript">
  $(document).ready(function () {
      /* The following code is executed once the DOM is loaded */

      $('.sponsorFlip').bind("click", function () {

          // $(this) point to the clicked .sponsorFlip element (caching it in elem for speed):

          var elem = $(this);

          // data('flipped') is a flag we set when we flip the element:

          if (elem.data('flipped')) {
              // If the element has already been flipped, use the revertFlip method
              // defined by the plug-in to revert to the default state automatically:

              elem.revertFlip();

              // Unsetting the flag:
              elem.data('flipped', false);
          }
          else {
              // Using the flip method defined by the plugin:

              elem.flip({
                  direction: 'lr',
                  speed: 350,
                  onBefore: function () {
                      // Insert the contents of the .sponsorData div (hidden from view with display:none)
                      // into the clicked .sponsorFlip div before the flipping animation starts:

                      elem.html(elem.siblings('.sponsorData').html());
                  }
              });

              // Setting the flag:
              elem.data('flipped', true);
          }
      });

  });

HTML:

代码语言:javascript
复制
<div class="sponsorListHolder">
            <div class="sponsor" title="Click to flip">
                <div class="sponsorFlip" >
                    <img src="Images/edan.png" alt="More about Edan" id="test" />
                </div>
                <div class="sponsorData">
                    <div class="sponsorDescription">
                        Edan
                    </div>
                    <div class="sponsorURL">
                        <!--                    <a href="#">Edan</a>-->
                    </div>
                </div>
            </div>

CSS:

代码语言:javascript
复制
.sponsorListHolder{
margin-bottom:30px;
}

.sponsor{
width:180px;
height:180px;
float:left;
margin:4px;

/* Giving the sponsor div a relative positioning: */
position:relative;
cursor:pointer;
}

.sponsorFlip{
/*  The sponsor div will be positioned absolutely with respect
    to its parent .sponsor div and fill it in entirely */

position:absolute;
left:0;
top:0;
width:100%;
height:100%;
border:1px solid #ddd;  

}

.sponsorFlip:hover{
border:1px solid #999;

/* CSS3 inset shadow: */
-moz-box-shadow:0 0 30px #999 inset;
-webkit-box-shadow:0 0 30px #999 inset;
box-shadow:0 0 30px #999 inset;
}

.sponsorFlip img{
/* Centering the logo image in the middle of the sponsorFlip div */

position:absolute;
top:50%;
left:50%;
margin:-70px 0 0 -70px;
}

.sponsorData{
/* Hiding the .sponsorData div */
display:none;
}

.sponsorDescription{
font-size:11px;
padding:50px 10px 20px 20px;
font-style:italic;
}

.sponsorURL{
font-size:10px;
font-weight:bold;
padding-left:20px;
}

我已经包含了jquery插件:

代码语言:javascript
复制
<script type="text/javascript" src="js/jquery.flip.min.js"></script>

问候

EN

回答 1

Stack Overflow用户

发布于 2013-09-09 16:36:47

我猜您已经添加了Jquery,您还可以添加Jquery UI

代码语言:javascript
复制
<script type="text/javascript" src="js/jquery-ui-1.10.3.custom.min.js"></script>

在此之前

代码语言:javascript
复制
<script type="text/javascript" src="js/jquery.flip.min.js"></script>

右边的http://lab.smashup.it/flip/提到这个插件依赖于Jquery和Jquery UI。

希望它能起作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18693584

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档