2016-10-13 108 views
0

this is how the blocks look likediv悬停对扩展的影响?

if i mouseover on test1 with hover effect ,it covers all block to its right but doesnot maximize full covering all block...i need solution for this

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Insert title here</title> 
    <script type=text/javascript src="jquery-1.11.0.min.js"></script> 
    <script type=text/javascript src="avc.js"></script> 
    <link href="amcstyle.css" rel="stylesheet" /> 
</head> 
<body> 

    <div class="twocol"> 
     <div class="inside">test0</div> 
     </div> 

    <div class="twocol"> 
     <div class="inside1">Test1</div> 
    </div> 
    <div class="twocol"> 
     <div class="inside2">Test3</div> 
    </div> 
    <div class="twocol"> 
     <div class="inside3">Test4</div> 
    </div> 
    <div style="clear:both"></div> 
    <div class="twocol"> 
     <div class="inside4">Test5</div> 
    </div> 
    <div class="twocol"> 
     <div class="inside5">Test6</div> 
    </div> 
    <div class="twocol"> 
     <div class="inside6">Test7</div> 
    </div>     

</body> 
</html> 

CSS

.twocol { 
    float: left; 
    width: 150px; 
    height: 150px; 
    position: relative; 
    padding: 10px; 
} 
.twocol1 { 
    width: 100px; 
    height: 100px; 
    position: relative; 
    padding: 10px; 
    background-color:pink; 
} 
.inside { 
    position: absolute; 
    border: 1px solid #000; 
    width: 150px; 
    height: 150px; 
    background: #eee; 
    z-index: 900; 
} 
.inside:hover { 
    position: absolute; 
    z-index: 999; 
transition: 0.5s ease; 


} 

脚本...目前管理div的扩张和大小我写了单独的脚本函数为每个

$(document).ready(function() { 

    $('.inside').hover(

      function() { 
       $(this).animate({ 
        height: '320px', 
        width: '660px' 
       }, 200); 
      }, 

      function() { 
       $(this).animate({ 
        height: '150px', 
        width: '150px' 
       }, 200); 
      }); 
}); 

$(document).ready(function() { 

    $('.inside1').hover(

      function() { 

       $(this).animate({ 
        height: '320px', 
        width: '500px' 

       }, 200); 

      }, 

      function() { 
       $(this).animate({ 
        height: '150px', 
        width: '150px', 

       }, 200); 
      }); 
}); 
$(document).ready(function() { 

    $('.inside2').hover(

      function() { 
       $(this).animate({ 
        height: '320px', 
        width: '320px' 
       }, 200); 
      }, 

      function() { 
       $(this).animate({ 
        height: '150px', 
        width: '150px' 
       }, 200); 
      }); 
}); 

$(document).ready(function() { 

    $('.inside3').hover(

      function() { 
       $(this).animate({ 
        height: '320px', 
        width: '150px' 
       }, 200); 
      }, 

      function() { 
       $(this).animate({ 
        height: '150px', 
        width: '150px' 
       }, 200); 
      }); 
}); 

$(document).ready(function() { 

    $('.inside4').hover(

      function() { 
       $(this).animate({ 
        height: '155px', 
        width: '500px' 
       }, 200); 
      }, 

      function() { 
       $(this).animate({ 
        height: '150px', 
        width: '150px' 
       }, 200); 
      }); 
}); 

$(document).ready(function() { 

    $('.inside5').hover(

      function() { 
       $(this).animate({ 
        height: '155px', 
        width: '320px' 
       }, 200); 
      }, 

      function() { 
       $(this).animate({ 
        height: '150px', 
        width: '150px' 
       }, 200); 
      }); 
}); 
$(document).ready(function() { 

    $('.inside6').hover(

      function() { 
       $(this).animate({ 
        height: '150px', 
        width: '320px' 
       }, 200); 
      }, 

      function() { 
       $(this).animate({ 
        height: '150px', 
        width: '150px' 
       }, 200); 
      }); 
}); 

回答

0

增加WidthHeight在动画节中添加
inside:hover{left:0}从左侧覆盖并同时删除.twocol {position:relative} .. 让我知道这是你在寻找什么

$(document).ready(function() { 
 

 
    $('.inside').hover(
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '400px', 
 
        width: '400px' 
 
       }, 200); 
 
      }, 
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '150px', 
 
        width: '150px' 
 
       }, 200); 
 
      }); 
 
}); 
 

 
$(document).ready(function() { 
 

 
    $('.inside1').hover(
 

 
      function() { 
 

 
       $(this).animate({ 
 
        height: '500px', 
 
        width: '900px' 
 
       }, 200); 
 

 
      }, 
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '150px', 
 
        width: '150px' 
 
       }, 200); 
 
      }); 
 
}); 
 
$(document).ready(function() { 
 

 
    $('.inside2').hover(
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '320px', 
 
        width: '320px' 
 
       }, 200); 
 
      }, 
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '150px', 
 
        width: '150px' 
 
       }, 200); 
 
      }); 
 
}); 
 

 
$(document).ready(function() { 
 

 
    $('.inside3').hover(
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '320px', 
 
        width: '150px' 
 
       }, 200); 
 
      }, 
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '150px', 
 
        width: '150px' 
 
       }, 200); 
 
      }); 
 
}); 
 

 
$(document).ready(function() { 
 

 
    $('.inside4').hover(
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '155px', 
 
        width: '500px' 
 
       }, 200); 
 
      }, 
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '150px', 
 
        width: '150px' 
 
       }, 200); 
 
      }); 
 
}); 
 

 
$(document).ready(function() { 
 

 
    $('.inside5').hover(
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '155px', 
 
        width: '320px' 
 
       }, 200); 
 
      }, 
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '150px', 
 
        width: '150px' 
 
       }, 200); 
 
      }); 
 
}); 
 
$(document).ready(function() { 
 

 
    $('.inside6').hover(
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '150px', 
 
        width: '320px', 
 
        left:'0' 
 
       }, 200); 
 
      }, 
 

 
      function() { 
 
       $(this).animate({ 
 
        height: '150px', 
 
        width: '150px', 
 
        left:'0' 
 
       }, 200); 
 
      }); 
 
});
.twocol { 
 
    float: left; 
 
    width: 150px; 
 
    height: 150px; 
 
    padding: 10px; 
 
} 
 
.twocol1 { 
 
    width: 100px; 
 
    height: 100px; 
 
    padding: 10px; 
 
    background-color:pink; 
 
} 
 
.inside { 
 
    position: absolute; 
 
    border: 1px solid #000; 
 
    width: 150px; 
 
    height: 150px; 
 
    background: #eee; 
 
    z-index: 900; 
 
} 
 
.inside:hover { 
 
    position: absolute; 
 
    z-index: 999; 
 
transition: 0.5s ease; 
 

 

 
} 
 
.inside1 { 
 
    position: absolute; 
 
    border: 1px solid #000; 
 
    width: 150px; 
 
    height: 150px; 
 
    background: #eee; 
 
    z-index: 900; 
 
} 
 
.inside1:hover { 
 
    position: absolute; 
 
    z-index: 999; 
 
transition: 0.5s ease; 
 
left:18px; 
 

 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
 
<html> 
 
<head> 
 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
 
<title>Insert title here</title> 
 
    <script type=text/javascript src="jquery-1.11.0.min.js"></script> 
 
    <script type=text/javascript src="avc.js"></script> 
 
    <link href="amcstyle.css" rel="stylesheet" /> 
 
</head> 
 
<body> 
 

 
    <div class="twocol"> 
 
     <div class="inside">test0</div> 
 
     </div> 
 

 
    <div class="twocol"> 
 
     <div class="inside1">Test1</div> 
 
    </div> 
 
    <div class="twocol"> 
 
     <div class="inside2">Test3</div> 
 
    </div> 
 
    <div class="twocol"> 
 
     <div class="inside3">Test4</div> 
 
    </div> 
 
    <div style="clear:both"></div> 
 
    <div class="twocol"> 
 
     <div class="inside4">Test5</div> 
 
    </div> 
 
    <div class="twocol"> 
 
     <div class="inside5">Test6</div> 
 
    </div> 
 
    <div class="twocol"> 
 
     <div class="inside6">Test7</div> 
 
    </div>     
 

 
</body> 
 
</html>

+0

为u说..我用左:0 – junior

+0

因为你说我用左:0和删除位置:相对来自两协议,但现在的问题是...我用剩下的块:0该块正在向左扩展,这很棒, ,但该块正在与左边的相邻块重叠... – junior

+0

http://tinypic.com/r/2aj9s2r/9 – junior