CSS中的常用屬性
顏色
字體顏色 color:red; color:#ff0000;
背景顏色 background-color:red; background-color:#ff0000;
邊框顏色 border:2px solid實線/dotted虛線 red;
線寬 實虛線 顏色
寬高
寬度 width:xx;
高度 height:xx;
字體
字體 font-family:xx;
字號/大小 font-size:xx;
(html中設置字體、字號和顏色: <font face=”” size=”1-7” color=””></font>)
水平方向對齊 text-align:left/center/right;
(說明1:該屬性適用於標記中的文字,但是標記必須是塊標記
說明2:行內標記設置水平方向對齊,必須把行內標記放在塊標記中)
行高 line-height:數字; 直接寫數字,表示幾倍行間距
縮進 text-indent:數字+em; em相當於中文字體中幾個縮進
代碼部分:
<html>
<head>
<title>CSS的常用屬性</title>
</head>
<body>
<div style="width:200px;height;200px;background-color:red">我是一個div標記</div>
<div style="width:200px;height;200px;background-color:red">我是一個div標記</div>
<p style="width:100px;height;100px;background-color:yellow">這是一個p標記</p>
<div style="font-family:楷體;font-size:50px;color:green">今天是星期一</div>
<div style="text-align:center;border:1px solid blue">你好</div>
<span style="text-align:center;border:1px solid red">hello</span>
<h1 style="text-align:center">早上好</h1>
<div style="text-align:center">
<span>hello</span>
</div>
<div style="background-color:yellow;text-align:center">
<img src="玫瑰.jpg" style="width:200px;height:100px"/>
</div>
<div style="line-height:2">
當你的才華還撐不起你的野心的時候,你就應該靜下心來學習;當你的能力還駕馭不了你的目標時,就應該沉下心來,歷練;夢想,不是浮躁,而是沉澱和積累,只有拼出來的美麗,沒有等出來的輝煌,機會永遠是留給最渴望的那個人,學會與內心深處的你對話,問問自己,想要怎樣的人生,靜心學習,耐心沉澱,送給自己,共勉。
</div>
<div style="line-height:2;text-indent:2em">
當你的才華還撐不起你的野心的時候,你就應該靜下心來學習;當你的能力還駕馭不了你的目標時,就應該沉下心來,歷練;夢想,不是浮躁,而是沉澱和積累,只有拼出來的美麗,沒有等出來的輝煌,機會永遠是留給最渴望的那個人,學會與內心深處的你對話,問問自己,想要怎樣的人生,靜心學習,耐心沉澱,送給自己,共勉。
</div>
</body>
</html>
插入的圖片:
玫瑰.jpg
效果圖: