航條效果圖:
我們先來看一下,首先這個整體我們可以看成一個大盒子,盒子的背景顏色為白色。
然后看一下整體的話是占到整個導航條的80%左右,上圖紅色框圈出的范圍。
這個盒子又分為兩個部分,左側的logo部分,右側的導航部分。
整個布局用到的是flex布局:
大家可以去看一下阮一峰老師的教程:
阮一峰flex布局
左側logo部分我們用到的標簽有:
1、h3標簽:
<h3><a href="index.html">多多魚網頁</a></h3>
h3是一對有開始有閉合的標簽組合。以<h3>開始,以</h3>結束。
html h3標簽主要用于布局標題、欄目類內容,h3與h1最大標題標簽相比,h1標簽一般一個網頁中使用一次,而h3標簽可以在一個網頁中多次使用。默認CSS h3又比h2文字大小小一點。
html h3標簽常見應用地方:
欄目標題可以使用h3標簽
文章標題可以使用h3標簽
文章標題列表可以使用h3標簽(一般圖文列表中,圖片使用img引入,文章標題文字使用h3標簽)
2、a標簽:
<a href="index.html">多多魚網頁</a>
<a> 標簽定義超鏈接,用于從一張頁面鏈接到另一張頁面。
<a> 元素最重要的屬性是 href 屬性,它指示鏈接的目標。
在所有瀏覽器中,鏈接的默認外觀是:
未被訪問的鏈接帶有下劃線而且是藍色的
已被訪問的鏈接帶有下劃線而且是紫色的
活動鏈接帶有下劃線而且是紅色的
右側的導航部分我們用到的標簽有:
一、無序列表簡介
無序列表,很好理解,有序列表的列表項是有一定順序的,而無序列表的列表項是沒有順序的。默認情況下,無序列表的項目符號是●,不過可以通過無序列表type屬性來改變無序列表的列表項符號。
語法:
<ul>
<li>無序列表項</li>
<li>無序列表項</li>
<li>無序列表項</li>
</ul>
說明:
<ul>,即“unordered list(無序列表)”。<li>,即“list(列表項)”。理解標簽語義更有利于你記憶,而記憶HTML標簽的語義是HTML的基礎。
在該語法中,使用<ul></ul>標簽表示一個無序列表的開始和結束,<li>表示這是一個列表項。在一個無序列表中可以包含多個列表項。
注意,<ul>標簽和<li>標簽也是配合使用,沒有單獨使用,而且<ul>標簽內部不能存在任何其他標簽,一般情況下只能存在<li>標簽(對于初學者,我們忽略嵌套列表)。這個概念要非常清楚,在網站開發后期很容易犯錯。(這個情況跟有序列表一樣)。
右側導航代碼:
<ul>
<li class="active">
<a href="index.html">首頁</a>
</li>
<li>
<a href="">網頁模板</a>
</li>
<li>
<a href="">學習資料</a>
</li>
<li>
<a href="">常見問題</a>
</li>
<li>
<a href="">網頁作業</a>
</li>
<li>
<a href="">聯系我們</a>
</li>
</ul>
視屏教程:
果圖
html部分:先寫用div畫好六個導航的卡片,再利用css添加響應效果
<div class='card-holder'>
<div class='card-wrapper'>
<a href='#'>
<div class='card bg-01'>
<span class='card-content'>item #1</span>
</div>
</a>
</div>
<div class='card-wrapper'>
<a href='#'>
<div class='card bg-02'>
<span class='card-content'>long menu item #2</span>
</div>
</a>
</div>
<div class='card-wrapper'>
<a href='#'>
<div class='card bg-03'>
<span class='card-content'>menu item #3</span>
</div>
</a>
</div>
<div class='card-wrapper'>
<a href='#'>
<div class='card bg-04'>
<span class='card-content'>item #4</span>
</div>
</a>
</div>
<div class='card-wrapper'>
<a href='#'>
<div class='card bg-05'>
<span class='card-content'>menu item #5</span>
</div>
</a>
</div>
<div class='card-wrapper'>
<a href='#'>
<div class='card bg-06'>
<span class='card-content'>long menu item #1</span>
</div>
</a>
</div>
</div>
css部分:通過hover選擇器和transition屬性實現導航響應式操作,即可實現如圖效果
a:link,
a:hover,
a:visited,
a:active {
color: #fff;
text-decoration: none;
}
body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
background: #fff;
}
.card-holder {
position: fixed;
width: 0px;
overflow: visible;
}
.card-wrapper {
display: inline-block;
float: right;
clear: both;
}
.card {
position: relative;
left: 32px;
padding: 16px 32px 16px 64px;
margin: 8px;
background: #fff;
transition: all 0.3s ease-in-out 0.1s;
}
//添加導航的響應式效果
.card:hover {
position: relative;
left: 100%;
margin-left: -32px;
transition: all 0.3s ease-in-out;
}
.card-content {
display: inline-block;
color: #fff;
font-family: 'Droid Sans', sans-serif;
font-size: 16px;
font-weight: bold;
white-space: nowrap;
}
.bg-01 { background: #539770; }
.bg-02 { background: #4B7D74; }
.bg-03 { background: #8DC2BC; }
.bg-04 { background: #EDD6B4; }
.bg-05 { background: #BE7467; }
.bg-06 { background: #E2AE63; }
然后就能實現我們這個實用又美觀的側邊導航欄啦
#goTopBtn, #goBottom, #shangy, #xiay, #menuPage, #lPage, #fPage{
width: 18px;
line-height: 1.2;
padding: 5px 0;
font-size: 12px;
text-align: center;
position: fixed;
right: 10px;
cursor: pointer;
filter: Alpha(opacity=30);
opacity=.3;
font-weight:bold;
}
#goTopBtn, #goBottom, #menuPage, #lPage, #fPage{
background-color:#999;
color:#000;
}
#shangy, #xiay, #lPage, #fPage{
background-color: #bbb;
color: #000;
}
#fPage{
bottom: 236px;
height:42px;
white-space:nowrap;
overflow:hidden;
//writing-mode:tb-rl;
}
#menuPage{
bottom: 198px;
height:27px;
white-space:nowrap;
overflow:hidden;
}
#lPage{
bottom: 145px;
height:42px;
white-space:nowrap;
overflow:hidden;
}
#goTopBtn{
bottom: 105px;
}
#goBottom {
bottom: 30px;
}
#shangy {
bottom: 80px;
}
#xiay {
bottom: 55px;
}
#goTopBtn:hover, #goBottom:hover, #shangy:hover, #xiay:hover, #menuPage:hover, #lPage:hover, #fPage:hover{
background-color:#ccc;
border:#ccc 0px solid;
}
#goTopBtn a:link, #goBottom a:link, #xiay a:link, #shangy a:link, #menuPage a:link, #menuPage a:visited, #lPage a:link, #fPage a:link, #lPage a:visited, #fPage a:visited {
text-decoration: none;
color:white;
}
<div id="fPage"><a id="fPagea" href="javascript:void(null)" target="_self">上<br />一<br />頁</a></div>
<div id="menuPage"><a href="index.html" target="_self">目<br />錄</a></div>
<div id="lPage"><a id="LPagea" href="javascript:void(null)" target="_self">下<br />一<br />頁</a></div>
<div style="display:none" id="goTopBtn"><a target="_self" style="color:#fff;">∧</a></div>
<div style="display:none" id="shangy">
<a onclick="shangy()" target="_self" style="color:#fff;">↑</a></div>
<div id="xiay">
<a onclick="xiay()" target="_self" style="color:#fff;">↓</a></div>
<div id="goBottom">
<a onclick="downn()" target="_self" style="color:#fff;">∨</a></div>
<script type=text/javascript>
goTopEx();
function xiay(){
window.scrollBy(0,window.innerHeight-10);
}
function shangy(){
window.scrollBy(0,-window.innerHeight+10);
}
var obj3=document.getElementById("xiay");
var obj4=document.getElementById("goBottom");
function getHeight(){
if(browser4=="ch"){
//谷歌瀏覽器
return document.body.clientHeight;
}else{
//IE、firefox等瀏覽器
return document.documentElement.clientHeight;
}
}
getHeight()<window.innerHeight+50?obj3.style.display="none":obj3.style.display="";
getHeight()<window.innerHeight+50?obj4.style.display="none":obj4.style.display="";
if(browser4!="ch"){//firefox需要嘗一下才顯示向下圖標
xiay();
shangy();
}
//上一頁、下一頁按鈕,需要文件名是數字
var strUrl=window.location.href;
var arrUrl=strUrl.split("/");
var thispage=arrUrl[arrUrl.length-1];
var thispage2=thispage.split(".");
var thispage3=thispage2[thispage2.length-2];
if(thispage3 == 1){
var obj5=document.getElementById("fPage");
obj5.style.display="none"
}else{
var fpage = thispage3 - 1;
fpage = fpage +".html"
document.getElementById("fPagea").href=fpage;
}
if(thispage3 == 100){
var obj6=document.getElementById("lPage");
obj6.style.display="none"
}else{
var fpage = thispage3 - 1;
fpage = fpage +".html"
document.getElementById("fPagea").href=fpage;
}
</script>
當將鼠標停留在“上一面”按鈕處時,網頁效果如下:
-End-
*請認真填寫需求信息,我們會在24小時內與您取得聯系。