jquery - 使用 JQuery 和 CSS 扩展/缩小 Div

标签 jquery css html expand

我正在尝试使用 JQuery 和 CSS 来允许用户浏览不同大小图像的“墙”。

基本上,当用户将鼠标悬停在图像上时,我希望它展开(目前正在运行)并且我希望 div 的宽度也增加,以显示一些额外的信息。出于某种原因,当我悬停在这一点上时,会出现一些非常奇怪的行为,当我鼠标移开时,图像会完全关闭。我有一种感觉,我在某处错过了一个“停止”,但我不知道在哪里。有人可以看一下吗?

JQuery:

jQuery(function($){
                $('.bar').mosaic({
                    animation   :   'slide'
                });
            });

HTML:

<div class="MBT-CSS3">
        <!--Bar-->
        <div class="mosaic-block bar">
            <a href="http://buildinternet.com/project/mosaic" target="_blank" class="mosaic-overlay">

                    <h4>This video is really cool!  Click to watch more!</h4>
                    <p>by Media Innovation Team</p>

            </a>


            <!-- <img src="http://buildinternet.s3.amazonaws.com/projects/mosaic/mosaic.jpg"/> -->
            <img src="img/grad1.png"/>

        </div>
  </div>

        <div class="clearfix"></div>

CSS

.MBT-CSS3 div{
-webkit-transform:scale(0.7); /*Webkit 0.7 times the original Image size*/
-moz-transform:scale(0.7); /*Mozilla 0.7 times the original Image size*/
-o-transform:scale(0.7); /*Opera 0.7 times the original Image size*/
-webkit-transition-duration: 0.5s; /*Webkit: Animation duration*/
-moz-transition-duration: 0.5s; /*Mozilla Animation duration*/
-o-transition-duration: 0.5s; /*Opera Animation duration*/
/*opacity: 0.5;
z-index: 1;*/
position:relative;
overflow:hidden;
background-color:#000;
width: auto;
height: auto;
/*margin: 0 10px 5px 0; */
}
.MBT-CSS3 div:hover{
-webkit-transform:scale(1.1); /*Webkit: 0.5 times the original Image size*/
-moz-transform:scale(1.1); /*Mozilla 0.5 times the original Image size*/
-o-transform:scale(1.1); /*Opera 0.5 times the original Image size*/
/*box-shadow:0px 0px 30px gray;
-webkit-box-shadow:0px 0px 30px gray;
-moz-box-shadow:0px 0px 30px gray; */
opacity: 1;
z-index: 100;
width:600px;
/*height:250px; */  
}

感谢任何可能提供帮助的人!!!!非常感谢您的宝贵时间!

最佳答案

试试这个:

                $(document).ready(function(){
          var busy = 0;
          $('.MBT-CSS3').mouseover(function(){
              if(!busy)
                  {
                      busy = 1;                      
                    $('#img').animate({
                   '-webkit-transform':'scale(1.1)',
                    '-moz-transform':'scale(1.1)',
                    '-o-transform':'scale(1.1)',
                    'opacity': '1',
                    'z-index': '100',
                    'width' : '600'
                  }, function(){busy = 0;});
                  }
          });
          $('.MBT-CSS3').mouseout(function(){
          if(!busy)
              {
                  busy = 1;                      
                    $('#img').animate({
                   '-webkit-transform':'scale(.7)',
                    '-moz-transform':'scale(.7)',
                    '-o-transform':'scale(.7)',
                    'opacity': '0.5',
                    'z-index': '1',
                    'width' : '300'
                  }, function(){busy = 0;});
              }
          });
      });

应该可以。我确实在您使用的图像中添加了一个 id="img"。希望这可以帮助!您可以根据需要添加/删除/编辑任何属性。 也删除了 CSS 的整个 .MBT-CSS3 :hover 部分。 为整个 'MBT-CSS3' 类编辑,抱歉 :)

关于jquery - 使用 JQuery 和 CSS 扩展/缩小 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6036933/

相关文章:

php - 根据下拉选择自动填充文本字段,其中所有值都来自 MYSQL 表

javascript - jQuery 代码将所有内容隐藏在我的 div 中

javascript - 代码在 jsfiddle 中有效,但在我的网站上无效

html - 带标签的圆形导航 Bootstrap

javascript - view.zoom 对于 paper.js 中的大 Canvas 尺寸渲染速度很慢

javascript - 使用 nivoSlider,如何确定当前幻灯片图像或索引?

javascript - 来自 jquery 插件的 angularjs 指令

html - 当 flexbox 元素以列模式包装时,容器不会增加其宽度

html - 在 WebKit 浏览器中滚动时背景颜色切换为透明

javascript - 滑动响应导航 - 加载和响应页面时闪烁