2015-12-01 53 views
0

我試圖複製這個網站上顯示的左右撥動: http://www.alexanderinteractive.com/company/josh左右撥動不顯示導航

我想申請在我的網站這個導航,但不能得到圖像現身。

這裏是我的代碼:

 #toggle { 
 
     position: absolute; 
 
     right: 30px; 
 
     top: 30px; 
 
     width: 104px; 
 
     z-index: 2; 
 
     } 
 
     #toggle a.prev { 
 
     background-image: url(http://www.onvia.com/sites/default/files/icon_arrow_left_150x150.png); 
 
     } 
 
     #toggle a.prev { 
 
     margin-right: 20px; 
 
     } 
 
     #toggle a.next { 
 
     background-image: url(http://www.onvia.com/sites/default/files/icon_arrow_right_150x150.png); 
 
     } 
 
     .clear:before, 
 
     .clear:after { 
 
     content: "\0020"; 
 
     display: block; 
 
     height: 0; 
 
     overflow: hidden; 
 
     }
<div id="toggle" class="clear"> 
 
    <a href="http://www.apple.com" class="prev">Previous</a> 
 
    <a href="http://www.microsoft.com" class="next">Next</a> 
 
</div>

回答

1

所有你需要做的就是添加

#toggle a { 
text-indent: -9999px; 
background-size: cover; 
width: 35px; 
height: 35px; 
display: inline-block; 
} 

text-indent刪除文本;父元素是position: absolute;,因此您需要爲元素設置heightwidth,並且background-size: cover;使背景圖像與包含元素允許的一樣大。 Here is the jsfiddle

+0

你可以告訴我的jsfiddle嗎?我試圖補充說,但我仍然沒有看到切換圖像 – user3075987

+0

我只是在現有的CSS上添加了新的樣式,並且它工作正常,這裏是鏈接http://jsfiddle.net/cr5dnsLt/ – Trug

0

你可以做這樣的。

#toggle { 
 
     position: absolute; 
 
     right: 30px; 
 
     top: 30px; 
 
     width: 104px; 
 
     z-index: 2; 
 
     } 
 
     #toggle a.prev { 
 
     display: inline-block; 
 
     width: 30px; 
 
     height: 30px; 
 
     background-size: contain; 
 
     background-image: url(http://www.onvia.com/sites/default/files/icon_arrow_left_150x150.png); 
 
     } 
 
     #toggle a.prev { 
 
     margin-right: 20px; 
 
     } 
 
     #toggle a.next { 
 
     display: inline-block; 
 
     width: 30px; 
 
     height: 30px; 
 
     background-size: contain; 
 
     background-image: url(http://www.onvia.com/sites/default/files/icon_arrow_right_150x150.png); 
 
     } 
 
     .clear:before, 
 
     .clear:after { 
 
     content: "\0020"; 
 
     display: block; 
 
     height: 0; 
 
     overflow: hidden; 
 
     }
<div id="toggle" class="clear"> 
 
    <a href="http://www.apple.com" class="prev"></a> 
 
    <a href="http://www.microsoft.com" class="next"></a> 
 
</div>

+0

你能告訴我jsfiddle嗎?我試圖添加,但我仍然沒有看到切換圖像 – user3075987

+0

當然,這是[小提琴](https://jsfiddle.net/LGSon/meLmnmj3/) – LGSon