1. 程式人生 > >【CSS】簡易的頁面側邊欄導航

【CSS】簡易的頁面側邊欄導航

這裡寫圖片描述

演示地址:點我

測試程式碼如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        /*左側邊欄*/
        a{
            text-decoration: none;
        }
        .sideBar {
            position: fixed;
            left: 20px
; top: 35%; }
.sideBar .ftName { position: relative; } .sideBar dl dd { position: relative; width: 80px; height: 80px; background-color: #646577; border-bottom: solid 1px #999; text-align
: center
; background-repeat: no-repeat; background-position: center 20%; cursor: pointer; }
.sideBar dd span { color: #fff; display: block; padding-top: 32px; } .sideBar .words span { padding-top
: 22px
; }
.sideInfo { position: absolute; left: 90px; top: 0; width: 250px; background-color: #646577; display: none; padding: 0 10px; } .words .sideInfo { padding: 6px 10px; } .sideInfo a, .sideInfo p { color: #fff; }
</style> </head> <body> <!--左側邊欄--> <div class="sideBar"> <dl> <dd class="ftName consult"> <a href="http://www.kytrack.com/"> <span>包裹查詢</span> </a> <div class="sideInfo"> <p>批量查詢跨境包裹物流派送資訊,支援郵政、DHL、UPS、EMS、FedEX等服務。</p> </div> </dd> <dd class="ftName words"> <a href="http://geren.kytrack.com/"> <span>進口個人<br>額度查詢</span> </a> <div class="sideInfo"> <p>查詢通過進口跨境電商渠道購買,已用額度。</p> </div> </dd> <dd class="ftName quote"> <a href="http://www.expecs.com/"> <span>快郵線上</span> </a> <div class="sideInfo"> <p>快郵線上物流綜合服務平臺為電商及外貿企業提供物流、通關、金融等服務。</p> </div> </dd> </dl> </div> <script src="js/jquery-1.11.3.js"></script> <script type="text/javascript"> /*側邊欄*/ $('.consult').hover(function(){ if($('.consult .sideInfo').is(':hidden')){ $('.consult .sideInfo').show(); }else{ $('.consult .sideInfo').hide(); } }); $('.words').hover(function(){ if($('.words .sideInfo').is(':hidden')){ $('.words .sideInfo').show(); }else{ $('.words .sideInfo').hide(); } }); $('.quote').hover(function(){ if($('.quote .sideInfo').is(':hidden')){ $('.quote .sideInfo').show(); }else{ $('.quote .sideInfo').hide(); } }); </script> </body> </html>