標籤:des style io color ar os 使用 java sp
WEB標準構成:
結構 HTML
樣式 CSS
行為 JavaScript(互動行為)
html代碼規範:
聲明doctype
UTF-8
標籤縮排
標籤小寫
注釋
<!doctypt html>
<meta charset="utf-8" />
<meta name="參數" content="name屬性值"/>
<meta name="keywords" content=""/>
<meta name="description" content=""/>
<title>網頁標題</title>
table標籤的屬性:
<caption>標題</caption>
<table cellpadding="0" cellspacing="0"> /* cellpadding相當於padding,cellspacing相當於margin */
<tr>表格的行
<th colspan="3">表頭儲存格</th> /* colspan:跨列,rowspan:跨行 */
<td>儲存格</td>
</tr>
</table>
ul、ol的區別:
ul—無序列表
<ul>
<li></li>
<li></li>
</ul>
ol—有序列表
<ol>
<li></li>
<li></li>
</ol>
css的引入方式以及優缺點:
外部引入:<link rel="stylesheet" type="text/css" href="css/index.css" />
優點:一個css檔案可控制多個頁面、易改版、便於維護、減少代碼量、代碼簡介規範 易於分工協作
缺點:相對於單頁有垃圾代碼、外部引入中的href屬性會給伺服器造成請求的壓力
——常用於訪問量巨大的網頁
頭部引入:<style></style>
優點:速度快、沒有伺服器請求壓力、相對於外部引入單頁代碼量少
缺點:不易改版與維護、代碼較亂不易前後台溝通
——常用於大型互連網首頁 如:網易、新浪等
標籤內引入:<div ></div>
優點:優先順序最高
缺點:餘代碼多、代碼量大、不利於維護
——個別特殊效果的使用
css選取器與書寫:
ID 選 擇器: #div1{ }
類 選 擇器: .div1{ }
標籤選取器: a/img/span/p/div1{ }
群組選取器: #div1,#div2,#div3{ }
後代選取器: #div1 .div2 a{ }
css選取器的優先順序:
html標籤的基本屬性: 塊屬性 行屬性
塊屬性標籤:
h1~h6
ol-有序列表
ul-無序列表
dl-定義列表
table-表格
p-段落
br-換行
行屬性標籤:
span-無語意標籤,類似於div,font-weight加粗;
a-定義錨,有利於seo搜尋引擎最佳化
img-定義圖片,用於在頁面中顯示圖片
var-定義文本的變數部分
strong-定義強調文本
em-定義強調文本
form-表單提交,用於提交資料
塊標籤可以嵌套塊標籤和列標籤,但列標籤只能嵌套列標籤!
列標籤可以通過給浮動或轉成塊屬性display:block;
textarea:定義多行的文本輸入控制項
select-定義挑選清單(下拉式清單)
option-定義挑選清單中的選項
<select>
<option>Volvo</option>
<option selected="selected">Saab</option>
<option>Mercedes</option>
<option>Audi</option>
</select>
input-定義文本變數部分,常用type屬性值如下:
<input type="text" name="" value="" onclick="" />
<input type="button" name="" value="" onclick="" />
<input type="submit" name="" value="" onclick="" />
<input type="gile" name="" value="" onclick="" />
<input type="heckbox" name="" value="" onclick="" />
<input type="radio" name="" value="" onclick="" />
<input type="password" name="" value="" onclick="" />
<input type="reset" name="" value="" onclick="" />
<input type="hidden" name="" value="" onclick="" />
css的樣式:
文本、字型:可同時為版面設定多個字型,當瀏覽器找不到第一個字型是會尋找第二個,知道找到可用字型。
font-family: "宋體",Arail,Tabhoma,sans-serif;
字型設定:1、中文頁面以宋體為首選,其他字型次之
2、英文頁面以Arail/Tahoma等字型
3、中英結合網站用英文字型
4、特殊字型一律用圖片
font-size: px/百分數/em;
font-style: normal(常規字型) / italic(斜體)/ oblique(傾斜)
font-weight: normal / bold / bolder(更粗) / lighter(更細)
font-color: #ffffff;
text-decoration: none / underline / overline(上劃線) / line-through(刪除線貫穿線)
line-height: normal / length;
text-indent: length/px/em;
text-align: left / center / right / justify(左右對齊);
vertical-align: top / bottom / middle(上下置中); 支援table其它標籤不建議使用
word-spacing: normal / length; 改變單詞間距
letter-spacing: normal / length; 改變字間距
background-color: red / #ffffff;
background-image: none / url("") 0 0 no-repeat;
background-position: x軸px% / y軸px%
background-attachment: scroll(背景圖跟著頁面滾動) / fixed(頁面滾動且背景圖不滾動);
background: color url("") position repeat;
border: 像素值 線條類型 線條顏色;
border-radius: 左上 右上 右下 左下
盒模型
padding:top right bottom left;
margin:top right bottom left;
border::top right bottom left;
display:inline-block;
標準模式:margin+padding+border+content
怪異模式:內容(padding+border+content)+margin
css布局
float:none / left /right; 浮動會導致文檔流塌陷
clear: none / left / right / both;
overflow: hidden(超出隱藏) /visible(顯示超出) / auto(在需要時剪下內容並添加捲軸) / acroll(顯示捲軸)
visibility(可視): visible(元素可視) / hidden(元素不可視) / inherit(整合父元素可視性);
position:reative / absolute / static(預設值) / fixed(可定位相對於瀏覽器視窗的指定座標) / inherit;
zindex: nomber / auto 設定元素的堆疊順序,正負值
opacity: number(0~1之間數值)
filter: alpha IE的半透明濾鏡fiter:alpha(opacity=50);
a標籤的偽類
a:link{}
a:visited{}
a:hover{}
a:active{}
常見相容問題
margin+float會出現雙倍間距-解決:用padding
border-radius IE8以下無效-解決:用背景圖圓角;
HTML+CSS小結