2013-02-19 123 views
0

因爲我正在jquery滑塊面板菜單上工作,我已經很好地實現了,但是當我單擊jquery滑塊菜單時,奇怪的問題依然存在。例如查看此鏈接(http://www.stickreloaded.com/demogame/simple-slide-panel.html#)請參閱我的以下代碼:Jquery滑塊面板閃爍

Regards, phphunger。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <title>Simple Slide Panel</title> 

    <script type="text/javascript" src="jquery.js"></script> 

    <script type="text/javascript"> 
    $(document).ready(function(){ 

     $(".btn-slide").click(function(){ 
      $("#panel").slideToggle("slow"); 
      $(this).toggleClass("active"); return false; 
     }); 


    }); 
    </script> 

    <style type="text/css"> 
    body { 
     margin: 0 auto; 
     padding: 0; 
     width: 990px; 
     font: 75%/120% Arial, Helvetica, sans-serif; 
    } 
    a:focus { 
     outline: none; 
    } 
    #panel { 
     background: #03111A; 
     height: 180px; 
     display: none; 
    } 
    .slide { 
     margin: 0; 
     padding: 0; 
     border-top: solid 4px #ffc000; 
     background: url(images/btn-slide.gif) no-repeat center top; 
     /*background-color: #ffc000; 
     height: 25px; 
     width: 30px; 
     -webkit-border-radius: 8px; 
    -moz-border-radius: 8px; 
    border-radius: 8px;*/ 
    } 
    .btn-slide { 
     background: url(images/white-arrow.gif) no-repeat right -50px; 
     /*background-color: #ffc000; 
     -webkit-border-radius: 8px; 
    -moz-border-radius: 8px; 
    border-radius: 8px;*/ 
     height: 25px; 
     width: 30px; 
     text-align: center; 
     width: 144px; 
     height: 31px; 
     padding: 10px 10px 0 0; 
     margin: 0 auto; 
     display: block; 
     font: bold 120%/100% Arial, Helvetica, sans-serif; 
     color: #fff; 
     text-decoration: none; 
    } 
    .active { 
     background-position: right 12px; 
    } 
    .moreList{float:left;margin:20px 0 0 20px;width:150px;} 
    .moreList li{margin-bottom:10px;} 
    .moreList li a{color:#fff;font-size:14px;font-weight:bold;} 
    .moreList li a:hover{color:#ee3524;} 
    #wrapper{ margin: 0 auto; 
    width: 1000px; height:auto; 
    -webkit-border-radius: 8px; 
    -moz-border-radius: 8px; 
    border-radius: 8px; 
    } 
    /*#content{ background:#03111a; 
    -webkit-border-radius: 8px; 
    -moz-border-radius: 8px; 
    border-radius: 8px;     
    margin-left: 5px; 
    margin-right: 5px; 
    margin-top: 10px; 
    margin-bottom: 5px; 
    overflow: hidden; }*/ 
    #content{ 
    background: #ff6801; /* Old browsers */ 
    -webkit-border-radius: 8px; 
    -moz-border-radius: 8px; 
    border-radius: 8px; 
    /* IE9 SVG, needs conditional override of 'filter' to 'none' */ 
    background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmNjgwMSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmNjMDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+); 
    background: -moz-linear-gradient(top, #ff6801 0%, #ffcc00 100%); /* FF3.6+ */ 
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ff6801), color-stop(100%,#ffcc00)); /* Chrome,Safari4+ */ 
    background: -webkit-linear-gradient(top, #ff6801 0%,#ffcc00 100%); /* Chrome10+,Safari5.1+ */ 
    background: -o-linear-gradient(top, #ff6801 0%,#ffcc00 100%); /* Opera 11.10+ */ 
    background: -ms-linear-gradient(top, #ff6801 0%,#ffcc00 100%); /* IE10+ */ 
    background: linear-gradient(to bottom, #ff6801 0%,#ffcc00 100%); /* W3C */ 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff6801', endColorstr='#ffcc00',GradientType=0); /* IE6-8 */ 
    } 
    </style> 
    </head> 

    <body> 

    <div id="panel"> 
     <!-- you can put content here --> 
     <ul class="moreList"> 
      <li><a href="#" id="tag_stick-figure" class="navTagLink">Ben 10</a></li> 

      <li><a href="#" id="tag_naughty" class="navTagLink">Batman</a></li> 

      <li><a href="#" id="tag_fighting" class="navTagLink">Spongebob</a></li> 

      <li><a href="#" id="tag_bloody" class="navTagLink">Scooby Doo</a></li> 

      <li><a href="#" id="tag_word" class="navTagLink">Power Rangers</a></li> 

      <li><a href="#" id="tag_political" class="navTagLink">Transformers</a></li> 

     </ul> 
      <ul class="moreList"> 
     <li><a href="#" id="tag_racing" class="navTagLink">Pokemon</a></li> 

      <li><a href="#" id="tag_motorsports" class="navTagLink">Avatar</a></li> 
      <li><a href="#" id="tag_flying" class="navTagLink">Mario</a></li> 

      <li><a href="#" id="tag_easy" class="navTagLink">Sonic</a></li> 
      <li><a href="#" id="tag_high-score" class="navTagLink">Naruto</a></li> 

      <li><a href="#" id="tag_map" class="navTagLink">Johnny Bravo</a></li> 

      </ul> 

      <ul class="moreList"> 
      <li><a href="#" id="tag_escape" class="navTagLink">Escape</a></li> 

      <li><a href="#" id="tag_tycoon" class="navTagLink">Tycoon</a></li> 

      <li><a href="#" id="tag_tower-defense" class="navTagLink">Tower Defense</a></li> 

      <li><a href="#" id="tag_random" class="navTagLink">Random</a></li> 
    <li><a href="#" id="tag_gross" class="navTagLink">Fighting</a></li> 

      <li><a href="#" id="tag_zombie" class="navTagLink">Shooting</a></li> 

     </ul> 

      <ul class="moreList"> 
      <li><a href="#" id="tag_hard" class="navTagLink">Spiderman</a></li> 

      <li><a href="#" id="tag_make-your-own" class="navTagLink">Billy and Mandy</a></li> 

      <li><a href="#" id="tag_dress-up" class="navTagLink">Flintstones</a></li> 

      <li><a href="#" id="tag_high-school" class="navTagLink">Looney Tunes</a></li> 
      <li><a href="#" id="tag_celebrity" class="navTagLink">Action</a></li> 

      <li><a href="#" id="tag_cute" class="navTagLink">Racing</a></li> 



     </ul> 


    </div> 

    <p class="slide"><a href="#" class="btn-slide">More Games</a></p> 

    <div id='wrapper'> 
    <div id='content'> 
    <div style="height: 450px;"> 
    </div> 
    </div> 
    </div> 

    </body> 
    </html> 
+0

這在Chrome中看起來很好。你使用的是什麼瀏覽器? – 2013-02-19 11:23:29

+0

在Firefox中看起來很好 – Morpheus 2013-02-19 11:27:24

+0

其實我使用firefox ..但是當我點擊滑塊向下或向下的div閃爍... – phphunger 2013-02-19 11:28:41

回答

0

雖然我無法複製它,但我想我以前遇到過這個問題。

嘗試在#panel格(它不能在%或em)上以像素爲單位添加固定寬度。

這可以防止當手風琴向下滑動時它跳過/跳過的異常jQuery錯誤(當它到達底部時,它是正確的)。

+0

其實我已經固定的寬度添加到面板,但仍然沒有運氣..更多的建議...... – phphunger 2013-02-19 12:12:03