2015-10-19 91 views
0

我該如何讓這段代碼滑出?當我點擊按鈕時,div滑出,但按鈕本身不會移動。另外我怎樣才能讓圖像和文字形成兩列?當使用我的IDE時,它顯示爲兩列,但在我的網站上沒有。如何獲得此滑塊的工作?

謝謝!

$(document).ready(function() { 
 
    $('.rec-anime-button').click(function() { 
 
    if (parseInt($('.rec-anime-list-container').css('right')) < 0) { 
 
     $('.rec-anime-list-container').css('right', '5px'); 
 
     $('.rec-anime-button').css('right', '500'); 
 
    } else { 
 
     $('.rec-anime-list-container').css('right', '-490px'); 
 
     $('.rec-anime-button').css('right', '0'); 
 
    } 
 
    }); 
 
});
.rec-anime-button { 
 
    position: fixed; 
 
    margin-top: 100px; 
 
    right: 0; 
 
    z-index: 1000000; 
 
} 
 
.rec-anime-list-container { 
 
    position: fixed; 
 
    margin-top: 100px; 
 
    right: -490px; 
 
    text-decoration: none; 
 
    transition: right 300ms ease-in-out; 
 
    z-index: 1000000; 
 
} 
 
.rec-anime-list { 
 
    max-width: 480px; 
 
    text-decoration: none; 
 
} 
 
.container li { 
 
    float: left; 
 
    width: 230px; 
 
    margin-right: 10px; 
 
    margin-bottom: 10px; 
 
    text-decoration: none; 
 
} 
 
.column { 
 
    display: inline-block; 
 
    vertical-align: middle 
 
} 
 
.rec-anime-title { 
 
    margin-top: 0; 
 
    color: gray; 
 
    width: 100px; 
 
} 
 
.sub { 
 
    color: blue; 
 
    font-size: 16px; 
 
} 
 
.dub { 
 
    color: red; 
 
    font-size: 16px; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<!-- Recommended Anime Slider --> 
 
<div class="rec-anime-button"> 
 
    <img src="/Rec-Anime-button.png"> 
 
</div> 
 
<div class="rec-anime-list-container"> 
 
    <ul class="rec-anime-list container"> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120xTITLE80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div> 
 
    </li> 
 
    <li> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div> 
 
    </li> 
 
    </ul> 
 
</div>

回答

0

試試下面的:我已經添加表中的每個Li和一個小的修改PF指定PX同時設定按鈕的樣式JS。

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 

 
<div class="rec-anime-button"> 
 
    <img src="http://static1.squarespace.com/static/51c4ae45e4b0e3594ecb840f/t/522e3eb4e4b0c5d6fd5ef60a/1378762451958/ARKHAM_Animation+Curve+Icon.png" style="width:80px;height:80px;"> 
 
</div> 
 
<div class="rec-anime-list-container"> 
 
    <ul class="rec-anime-list container"> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div> 
 
     </td></tr></table> 
 
    </li> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120xTITLE80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div></td></tr></table> 
 
    </li> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div></td></tr></table> 
 
    </li> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div></td></tr></table> 
 
    </li> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div></td></tr></table> 
 
    </li> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div></td></tr></table> 
 
    </li> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div></td></tr></table> 
 
    </li> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div></td></tr></table> 
 
    </li> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="sub">[Sub]</strong> 
 
     </div></td></tr></table> 
 
    </li> 
 
    <li><table><tr><td> 
 
     <a href="#"> 
 
     <div class="column"> 
 
      <img src="http://dummyimage.com/120x80/000/fff" /> 
 
     </div> 
 
     </a></td><td> 
 
     <div class="column rightcol"> 
 
     <p class="rec-anime-title">TITLE</p><strong class="dub">[Dub]</strong> 
 
     </div> 
 
    </li></td></tr></table> 
 
    </ul> 
 
</div> 
 

 
<script> 
 

 
$(document).ready(function() { 
 
\t $('.rec-anime-button').click(function() { 
 
\t  if (parseInt($('.rec-anime-list-container').css('right')) < 0) { 
 
\t  $('.rec-anime-list-container').css('right', '5px'); 
 
\t  $('.rec-anime-button').css('right', '500px');//use px 
 
\t  } else { 
 
\t  $('.rec-anime-list-container').css('right', '-490px'); 
 
\t  $('.rec-anime-button').css('right', '0px');//use px 
 
\t  } 
 
\t }); 
 
\t }); 
 
</script> 
 
<style> 
 
.rec-anime-button { 
 
    position: fixed; 
 
    margin-top: 100px; 
 
    right: 0; 
 
    z-index: 1000000; 
 
} 
 
.rec-anime-list-container { 
 
    position: fixed; 
 
    margin-top: 100px; 
 
    right: -490px; 
 
    text-decoration: none; 
 
    transition: right 300ms ease-in-out; 
 
    z-index: 1000000; 
 
} 
 
.rec-anime-list { 
 
    max-width: 480px; 
 
    text-decoration: none; 
 
} 
 
.container li { 
 
    float: left; 
 
    width: 230px; 
 
    margin-right: 10px; 
 
    margin-bottom: 10px; 
 
    text-decoration: none; 
 
} 
 
.column { 
 
    display: inline-block; 
 
    vertical-align: middle 
 
} 
 
.rec-anime-title { 
 
    margin-top: 0; 
 
    color: gray; 
 
    width: 100px; 
 
} 
 
.sub { 
 
    color: blue; 
 
    font-size: 16px; 
 
} 
 
.dub { 
 
    color: red; 
 
    font-size: 16px; 
 
} 
 
ul{ 
 
    list-style-type: none; 
 
} 
 
</style>

+0

非常感謝!這工作好很多。 –

+0

問題:這是網站:www.otakume.net 這些列仍然不起作用並顯示項目符號點。我該如何解決? –

+0

@OtakuMe嘗試更新的one.and如果有幫助,則將其標記爲幫助稍後訪問者的答案。 –