樣式表的幾點常用:background-color: 背景顏色 background-image:url 設置圖片背景 background-repeat平鋪 repeat-x 橫向平鋪 background-position:center 背景居中 background-position:righ ...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CSS樣式表</title> <style type="text/css"> .divclassB{ width:100px; height:100px; border:1px green dotted; background:#0F0 ; margin-top:10px; } *{ font:"黑體"; margin:0px; padding:0px;} div{ background-color:#C00} #DD{ width:100px; height:100px; border:1px green dotted; background:#0F0 ; margin-top:10px; } </style> <link href="Untitled-2.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="divclassA" style="width:100px; height:100px; border:1px red solid;">內聯樣式表</div> <div class="divclassB">內嵌樣式表</div> <div class="divclassC"></div> <div class="divclassD" id="DD" name="dd"></div> </body> </html>
樣式表的幾點常用:background-color: 背景顏色
background-image:url 設置圖片背景
background-repeat平鋪 repeat-x 橫向平鋪
background-position:center 背景居中
background-position:right top 圖片在右上角
font-family 字體
font-weight:bold 加粗
font-style:italic 傾斜
text-decoration:underline下劃線
text-align:center 水平居中對齊 left right
vertical-align:middle 垂直居中 top bottom
{margin in:opx auto;}自動居中
hover 滑鼠移上去
position與absolute
外層沒有position:absolute(或relative),div相對於瀏覽器定位。有的話,div相對於邊框定位
.divclassA :hover{cursor:pointer}有小手
a{ text-decoration:none}有下劃線
a:hover{text-decoration:underline}滑鼠移上去有下劃線
a:active{background:black}點擊一瞬間背景變黑
a:visited 所有被訪問的鏈接
導航欄簡易製作
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title> <style type="text/css"> #nav{ width:800px; height:100px; border:1px solid black; margin:0px auto; } .nav-banner{ text-align:center; line-height:100px; width:20%; height:100px; float:left; position:relative; } .nav-banner:hover{ background-color:#0F9; color:#F00; cursor:pointer; } </style> </head> <body> <div id="nav"> <div class="nav-banner">第一導航</div> <div class="nav-banner">第二導航</div> <div class="nav-banner">第三導航</div> <div class="nav-banner">第四導航</div> <div class="nav-banner">第五導航</div> </div> </body> </html>