0
-------------
| header |
------------
| | |
| L|content |
| | |
-------------
-------------
| header |
----------------
| <- | |
| L |content |
| <- | |
-----------------
我需要創建一個250像素寬度和300高度的JQuery框。它將包括(1)標題(2)左邊的一個小欄,它應該將左側的病房(顯示菜單)切換,並且在點擊時回到原始位置,以及(3)內容的右側部分。我在JQuery中相當新,並且可以想到下面的代碼,它們在Chrome中或多或少地工作,但在IE中失敗很多。從背景向左滑動菜單
<html>
<head>
<script src="jquery[1].js" type="text/JavaScript"></script>
<style type="text/css">
#gcontainer {
height:300px;
width:350px;
background-color:#ffffff;
margin-left:100px;
}
#gheader{
height:50px;
width:350px;
background-color:#feee00;
}
#gtray{
height:250px;
background-color:#006600;
width:130px;
float:left;
margin-left:0px;
margin-right:0px;
position:relative;
z-index:0;
overflow:hidden:
}
#gcontainer{
height:250px;
width:320px;
margin-left:30px;
background-color:darkblue;
float:left;
position:absolute;
}
</style>
<script type="text/JavaScript">
$(function(){
$('#gtray').toggle(
function()
{
$(this).stop(true).animate({marginLeft:'-100px'},'slow');
},
function()
{
$(this).stop(true).animate({marginLeft:'0px'},'slow');
});
});
</script>
</head>
<body>
<div id="gcontainer">
<div id="gheader"><h2>HEADER</h2></div>
<div id="gtray">
<span id="expander" style="width:30px;height:250px;float:left;background-color:red">O<br>p<br>e<br>n</span>
<span style="float:left">asdas<br>SDasd<br>asdasdasd<br>asdasd<br>Sdasd</span>
</div>
<div id="gcontainer"></div>
</div>
</body>
</html>
請建議。
嗨Sanketh ...謝謝。它在IE和Chrome中都很出色。但是,仍然存在一個小毛刺...當滑動托盤向左滾動時,您會看到滑動條會稍微改變其寬度,導致「打開」切斷一秒。如何解決這個問題,因爲它不會產生整潔和整潔的動畫。謝謝。 – helloworld
如果您放慢幻燈片(以毫秒爲單位將「慢」更改爲數字),它可能會看起來更平滑一些。如果你只是擔心文本被切斷,你可以在Open上添加一些填充。除此之外,您可能需要考慮使用另一個工具,如[jQuery Easing Plugin](http://gsgd.co.uk/sandbox/jquery/easing/)或[jQuery UI的效果](http:// jqueryui .com/docs/effect /),這可能會提供更多的平滑選項。希望那些幫助 –