2012-03-24 8 views
0

右から左にスライドする2つのdivがあります。私は "矢印"という名前の事業部が「インナー」という名前の事業部を左にスライドさせているだけで問題を抱えています。Jquery水平スライディングタブ機構

<script language="javascript" src="http://code.jquery.com/jquery-1.5.2.js"></script> 
<script language="javascript"> 
$(document).ready(function() { 
     var out = 0; 
     $("#arrow").click(function(){ 
     if(out==0) 
     { 
      $("#inner").animate({marginRight: "0px"}, 500); 
      out=1; 
     } 
    else 
     { 
     $("#inner").animate({marginRight: "-100px"}, 500); 
     out=0; 
     } 
    }); 
}); 
</script> 

<div style="background-color: rgb(204, 204, 204); height: 300px; width: 300px; overflow: hidden;"> 
    <div id="inner" style="height: 100px; width: 100px; background-color: rgb(0, 204, 102); float: right; margin-right:-100px;" >Form is here</div> 

    <div id="arrow" style="height: 100px; width: 50px; background-color: rgb(255, 0, 0); float: right; cursor: pointer;" >Arrow is here</div> 


</div> 

答えて

3

これを試してみてください:

<div style="background-color: rgb(204, 204, 204); height: 300px; width: 300px; overflow: hidden; position: relative;"> 
<div id="inner" style="height: 100px; width: 100px; background-color: rgb(0, 204, 102); float: right; margin-right:-100px;" >Form is here</div> 

<div id="arrow" style="height: 100px; width: 50px; background-color: rgb(255, 0, 0); float: right; cursor: pointer; position: absolute; top: 0; right: 0;" >Arrow is here</div> 


</div> 
+0

おかげでチームメイト!私はそれが欲しかったように完璧に働いた。 – CodingWonders90