前端基礎 03 CSS屬性

2021-08-10 19:00:35 字數 2836 閱讀 2526

#1.瀏覽量預設的字型微軟雅黑

font-family: "adobe arabic";

#2.字型大小設定

1.px 預設畫素

2.rem 對應瀏覽器預設的字型大小,瀏覽器是1rem=16px

google瀏覽器是 16px,最小是12px

3.em 等於父級的字型尺寸--相對父級字型大小而言

4.%相對父級的字型百分比而言

/*font-size: 22px;*/

/*font-size: 2rem;*/

/*font-size: 2em;*/

/*font-size: 50%;*/

#3.font-weight 字型粗細

關鍵字:

normal 預設字型

lighter 較細

bolder 很粗

預設給值:

只能是100-900的整百數

400正常的

700相當於bold

/*font-weight: bold;*/

#4.font-style 字型型別

normal 預設字正常

italic 文字斜體(屬性)

oblique 文字斜體

font-style: oblique;

#5.color字型顏色

1.關鍵字:aqua、green

2.16進製制: #dd55aa;或者#d5a

3.rgb(0-255,0-255,0-255):rgb(221,85,170)

r:red

g:green

b:blue

4.rgba(0-255,0-255,0-255,0-1)(221,85,170,0.5)

r:red

g:green

b:blue

a:alpha(透明度) 0完全透明

/*color: aqua;*/

/*color: #dd55aa;*/

/*color:rgb(221,85,170) ;*/

color:rgba(221,85,170,0.5) ;

#1.文字線屬性:text-decoration

text-decoration:

下劃線:underline

上劃線:overline

刪除線:line-through

none:預設值,可以用這個屬性去掉帶下劃線、上劃線、刪除線

/*text-decoration: underline;*/

/*text-decoration: overline;*/

text-decoration: line-through;

#2.文字大小寫:text-transform:

none:無特殊處理

uppercase:文字大寫

lowercase:文字小寫

capitalize:英文的首字母大寫

/*text-transform: uppercase;*/

/*text-transform: capitalize;*/

text-transform: lowercase;

#3.text-align:對齊方式,文字和image有效

left預設值:左對齊

right:右對齊

center:中間對齊

text-align: left;

#4.text-indent:首行縮排

text-indent: 2em;

#5.line-height:行高

line-height: 30px

#6.letter-spacing:字距

letter-spacing: 10px;

#7.word-spacing:單詞之間的距離

word-spacing: 20px;

#1. 背景顏色:background-color

background-color: red;

#2.背景:background-image

background-image: url("image/test1.ico")

#3.背景平鋪:background-repeat

no-repeat 平鋪

repeat 不平鋪

repeat-x 平鋪x

repeat-y 平鋪y

background-repeat: no-repeat;

#4.背景位置:background-position

x軸 left center right

y軸 left center right

如果只是給乙個值,預設是x軸,y軸預設center

% px %,px不能交換位置資訊,預設是x和y

background-position: left;

#5.背景的大小

使用 % px

auto等比縮放

cover 等比縮放,直到鋪滿xy

contain 等比縮放,鋪滿x或者y

background-size:contain;

#簡寫版本:

background: red url("image/test1.ico") no-repeat 50px 60px/contain;

vertical-align 垂直對齊方式

baseline 預設

top 頂部

middle 中部

bottom 底部

加vertical-align同排元素都需要新增

text-bottom 文字底部對齊

text-top 文字頂部對齊

CSS基礎03 CSS字型屬性

css fonts 字型 屬性用於定義字型系列 大小 粗細 文字樣式 如斜體等 css使用font family屬性定義文字的字型系列。pstyle css使用 font size屬性設定字型大小 pstyle css使用 font weight屬性來設定字型粗細,屬性值有normal 正常字型,相...

wep前端入門03 CSS基礎選擇器

cascading style sheets 層疊樣式表 層疊 多個樣式可以作用在同乙個html的元素上,同時生效 作用 用於頁面美化和布局控制1.功能強大 2.將內容展示和樣式控制分離 降低耦合度。解耦 讓分工協作更容易 提高開發效率css與html結合方式 內聯樣式在標籤內使用style屬性指定...

03 css形狀 css揭秘

形狀 一 自適應的橢圓 1.難題 1 圓 你可能注意到過,給任何正方形元素設定乙個足夠大的border radius,就可以把它變成乙個圓形。所用到的css 如下所示 1 bd 當任意兩個相鄰圓角的半徑之和超過border box 的尺寸時,使用者 必須按比例減小各個邊框半徑所使用的值,直到它們不會...