html css樣式
阿新 • • 發佈:2017-11-11
-s mar width ... style屬性 ott ons pad 默認
css樣式:
1. 標簽的style屬性
2. 寫在head裏面 style標簽中寫樣式
- id選擇區
#i1{
height: 48px;
}
- class選擇器 ******
.名稱{
...
}
<標簽 class=‘名稱‘> </標簽>
- 標簽選擇器
div{
...
}
所有div設置上此樣式
- 層級選擇器(空格) ******
.c1 .c2 div{
}
- 組合選擇器(逗號) ******
#c1,.c2,div{
}
- 屬性選擇器 ******
對選擇到的標簽再通過屬性再進行一次篩選
.c1[n=‘alex‘]{ width:100px; height:200px; }
PS:
- 優先級,標簽上style優先,編寫順序,就近原則
2.5 css樣式也可以寫在單獨文件中
<link rel="stylesheet" href="commons.css" />
3、註釋
/* */
4、邊框
- 寬度,樣式,顏色 (border: 4px dotted red;)
- border-left
5、
height, 高度 百分比
width, 寬度 像素,百分比
text-align:ceter, 水平方向居中
line-height,垂直方向根據標簽高度
color、 字體顏色
font-size、 字體大小
font-weight 字體加粗
6、float
<div style="clear: both;"></div>
7、display
display: none; -- 讓標簽消失
display: inline;
display: block;
display: inline-block;
具有inline,默認自己有多少占多少
具有block,可以設置無法設置高度,寬度,padding margin
******
行內標簽:無法設置高度,寬度,padding margin
塊級標簽:設置高度,寬度,padding margin
8、padding margin(0,auto)
html css樣式