標籤:style http color os io for 檔案 ar art
完整的HTML結構
<!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>
<title></title>
</head>
<body>
</body>
</html>
樣式的引用
一。內部編寫
<head>
<title> </title>
<style type="text/css">
body {background:black; text-spacing:0.5em}
.div_css1 {align="center" margin:20px}
.p_css1 {color:red; font:(Style)itlic||oblique (variant)small-caps||none (weight)800(400=norml 700=bold) (size)4em (family)“宋體”||Times New Norman}
</style>
<div class="">
(if ues: so use the style just 1 times)!!!
#div_css {}
<div id="">
(or ues: so don‘t write"class or id =?" )
div.p {}
div p {}
二。外部參考
<link rel="stylesheet" type="text/css" href="xx.css">
超連結的樣式
a {} // all super links
a:link {} //no linked links
a:visited{} //alredy linked links
a:hover{} //on mose move to the link
a:action{} // 點擊時
插入flash檔案
<object type="application/x-shockwave-flash" date="///" width="" height="" id="">
<param name="movie" value="///"/>
<param name="allowscriptAcess" value="sameDomain"/>
<param name="quality" value="best"/>
<param name="bgcolor" value="#FFFFFF"/>
<param name="scale" value="noScale"/>
<param name="salign" calue="TL"/>
<param name="FlashVars" value="playerMode=embedded"/>
</object>
插入視頻
<object type="video/x-ms-wmv" date="////xx" width="" height="">
<param name="src" value="////xx"/>
<param name="autostart" value="true"/>
<param name="controller" value="true"/>
</object>
插入網頁塊
<iframe
src="xx"
width=""
height=""
scrolling="auto"
frameborder="o"
name="xx">
</iframe>
插入表單
<form action="#" name="" id="" method="post"> </form>
一。文本輸入(帳號,密碼)
帳號<input type="text" name="" id="" maxlenth=""/>
密碼<input type="password" name="" id="" maxlenth=""/>
二。提交表單
<input type="submit" name="" id="" value="確認"></input>
三。單選
<input type="radio" name="" id="" value="xx">xx</input>
<input type="radio" name="" id="" value="xx">xx</input>
四。多選
<input type="checkbox" name="" id="" vslue="xx">xx</input>
<input type="checkbox" name="" id="" vslue="xx">xx</input>
<input type="checkbox" name="" id="" vslue="xx">xx</input>
五。下拉式功能表
<select name="" id="">
<option vslue="xx">xx</option>
<option vslue="xx">xx</option>
<option vslue="xx">xx</option>
</select>
六。列表(沒有下拉)
<select name="" id="" size="個數">
<option value="">xx</optin>
.......
......
</select>
懸浮文字框
<fieldset>
<legend>xx</legend>
</fieldset>
滾動文字
<maquee direction="up || left" scrollamount="0-x" onmouseover="stop()" onmouseout="start()">
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
</marquee>
表格
<table>
<tr>
<td>xx</td>
</tr>
<tr>
<td colspan="num">xx</td> //合并橫向
<td rowspan="num">xx</td> //合并豎向
</tr>
</table>
文字的一些屬性
設定元素內容的文字屬性
(1)舉例設定文本首行縮排
text-indent:2em;
(2)舉例設定文本對齊
text-align:left | right | center;
(3)舉例設定文本修飾方式
text-decoration:underline;
(4)舉例設定字間距
letter-spacing:2em;
(5)舉例設定詞間距
word-spacing:0.5em;
(6)舉例空白顯示形式 P56
white-space:pre;
外邊距margin:圍繞在元素邊框之外的可選地區。
內邊距padding:常值內容到邊框之間的可選地區
元素浮動
浮動:
float
有2個方向: left right none(不浮動)
對於文字浮動,必須設定高度,寬度,如果不設,後後果自負。
例
<img style="float:right" src="..."/>
清除浮動:
clear:none; //允許元素的兩邊都可以有浮動
clear:left; //不允許左邊有浮動元素
clear:right; //不允許右邊有浮動元素
clear:both; //兩邊都不允許有浮動元素
定位類型position
分類:
static(靜止)此為預設,即按照正常的文字資料流,佔用正常的位置。
fixed(固定的) 相對於瀏覽器視窗定位(保留原位置)
position:absolute;
絕對位置:相對於父級元素(被包含容器)。
position:relative;
相對定位:相對於沒有設定position時的正常位置定位
原始空間會保留下來。(意思就是說按static的位置算的地方不會出現另外的標籤。如DIV,IMG等等。)
例子:
<head>
<style type="text/css">
.div_1 {width:150px;height:200px;}
.text1 {width:200px;height:100px;left:160px;}
</style>
</head>
<body>
<div>
<div class="div_1" style="position:absolute;">
哈,我是一個帥哥
</div>
<div class="text1" style="position:absolute;">
是不是哦,我暈你
</div>
<div style="position:relative;left:10px;top:15px;">
我看看行不行。</div>
</div>
</body>
運行結果為:哈我是一個帥哥 是不是哦,我暈你
我看看行不行。
解釋:“哈我是一個帥哥”用的是absolute 絕對位置,它相對於第一個DIV來定位,因為第一個DIV是它的父級元素,將它包含在裡面。所以它出現在頂部起頭。(因為沒對其設定left 和top等)
“是不是哦,我暈你”也是absolute 絕對位置,它相對於第一個DIV定位,設定了left值為160px,大於上一個div的寬度,所以不會重合。
“我看看行不行”用的是relative 相對定位,它相對與父級元素定位,也就是第一個DIV,它定位的位置從父級元素裡面的最開始位置算起,所以,如果不設定top的話就會和第二個div重合。而字型的大小一般為15px‘
指定裁剪地區
position:absolute;
clip:rect(top right bottom left);
top:從上到下裁去top的長度。
left:從左至右裁去left的長度。
right:從左至右裁出right的長度。
bottom:從上到下裁出bottom的長度
將區塊層級元素轉化為字元級元素
display:inline;
將字元級元素轉化為區塊層級元素
display:block;
處理溢出
position:absolute;(必須為absolute)
overflow:visible; //溢出地區可見
overflow:hidden; //溢出地區不可見
overflow:scroll; //溢出地區出現捲軸
盒模型
有 margin padding border width height
簡寫時安上右下左順序來寫
如:border-width:1em 2em 2em 2em
注意:上下左右這幾個屬性:
在設定時如果只出現3個值,則代表上 左右 下
2個值: 上下 左右
1個值:全部 =出現4個一樣的值
插入多媒體
<embed src="1.swf" width=300 height=200></embed>
<embed src="1.mp3" width=300 height=200></embed>
<embed src="1.wmv" width=300 height=200></embed>
轉載
html+css基礎