H5 pembangunan responsif bar navigasi responsif

Susun atur halaman utama

QQ截图20161201104402.png

Bar navigasi

Selepas kami mempunyai fail yang diimport, kami mula menulis.

Mula-mula buat <nav> label bar navigasi menggunakan gaya bar navigasi terbina dalam bootstrap.

class="navbar navbar-default navbar-fixed-top"

Buat logo pengepala

<div> 
<a href="#" style="padding: 0; "><img src="https://img.php.cn/upload/course/000/000/004/5819475ea4910787.png" height="50" alt="PHP中文网"></a>
</div>

Kendalikan logo avatar, tetapkan jidar dalam kepada 0 dan buat lajur boleh lipat dalam bar navigasi

<div class="collapse navbar-collapse"id="navbar-collapse">
         <ul class="nav navbar-nav navbar-right" style="margin-top: 0">
            <li><a href="#"><span class="glyphicon glyphicon-home"></span> 首页</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-bookmark"></span> 资讯</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-fire"></span> 实例</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-envelope"></span> 关于我们</a></li>
         </ul>
      </div>

Gunakan kaedah runtuh yang disertakan dengan pemalam, tambahkan nama lajur pada senarai tidak tertib dan gunakan ikon Cantikkan terbina dalam

<span class="glyphicon glyphicon-home"></span>


<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <title>PHP中文网</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<style>
    .logo{
        padding: 0;
    }
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <a href="#" class="navbar-brand logo" ><img src="https://img.php.cn/upload/course/000/000/004/5819475ea4910787.png" height="50" alt="PHP中文网"></a>
        </div>
        <div class="collapse navbar-collapse"id="navbar-collapse">
            <ul class="nav navbar-nav navbar-right daohang " >
                <li class="active"><a href="#"><span class="glyphicon glyphicon-home"></span> 首页</a></li>
                <li><a href="#"><span class="glyphicon glyphicon-bookmark"></span> 资讯</a></li>
                <li><a href="#"><span class="glyphicon glyphicon-fire"></span> 实例</a></li>
                <li><a href="#"><span class="glyphicon glyphicon-envelope"></span> 关于我们</a></li>
            </ul>
        </div>

    </div>
</nav>
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script type="text/javascript">

</script>
</body>
</html>

Dengan cara ini bar navigasi kepala kami selesai.


Kesukaran bab ini

  1. Tulis bar navigasi kepala adaptif.

  2. Penggunaan asas bootstrap

Meneruskan pembelajaran
||
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no"> <title>PHP中文网</title> <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css"> <style> .logo{ padding: 0; } </style> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <a href="#" class="navbar-brand logo" ><img src="https://img.php.cn/upload/course/000/000/004/5819475ea4910787.png" height="50" alt="PHP中文网"></a> </div> <div class="collapse navbar-collapse"id="navbar-collapse"> <ul class="nav navbar-nav navbar-right daohang " > <li class="active"><a href="#"><span class="glyphicon glyphicon-home"></span> 首页</a></li> <li><a href="#"><span class="glyphicon glyphicon-bookmark"></span> 资讯</a></li> <li><a href="#"><span class="glyphicon glyphicon-fire"></span> 实例</a></li> <li><a href="#"><span class="glyphicon glyphicon-envelope"></span> 关于我们</a></li> </ul> </div> </div> </nav> <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script type="text/javascript"> </script> </body> </html>
  • Cadangan kursus
  • Muat turun perisian kursus