在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ HTML/ 文本
書單
JavaScript 動畫
HTML
CSS Reset
屬性操作
DOM 事件
閉包
Photoshop
Atom 文本編輯器
表單操作
布局解決方案
類型系統(tǒng)
開發(fā)實踐
數(shù)據(jù)通信
變量作用域
BOM
JavaScript 程序設計
前端工程師概述
CSS
響應式布局
表達式與運算符
基本語法
JavaScript 介紹
版本控制
布局
調試器
背景
圖片保存
多媒體
文檔樹
列表操作
Sublime 編輯器
盒模型
常見布局樣例
類型識別
變形
數(shù)據(jù)存儲
選擇器
頁面架構
開發(fā)及調試工具
頁面模塊化
節(jié)點操作
測量及取色
瀏覽器兼容
HTML 簡介
內置對象
實體字符
產(chǎn)品前端架構
協(xié)作流程
切圖
工具, 面板, 視圖
正則表達式
動畫
語句
面向對象
HTML 語法
HTML 標簽
技術選擇
樣式操作
圖片優(yōu)化與合并
語法
DOM 編程藝術
Canvas
接口設計
頁面優(yōu)化
文本

文本

文本

See the Pen FEND_Fonts by Li Xinyang (@li-xinyang) on CodePen.

字體

改變字號

font-size: <absolute-size> | <relative-size> | <length> | <percentage> | inherit

  • <absolute-size> 有 small large medium
  • <relative-size> 有 smaller larger
div
  font-size 12px
  p#sample0
    font-size 16px
  p#sample1
    font-size 2em
  p#sample2
    font-size 200%

NOTE:以上兩值在開發(fā)中并不常用。2em200% 都為父元素默認大小的兩倍(參照物為父元素的字體大小 12px)。

改變字體

font-family: [ <family-name> | <generic-family> ]#

<generic-family> 可選選項,但具體使用字體由瀏覽器決定

  • serif
  • sans-serif
  • cursive
  • fantasy
  • monospace
font-family: arial, Verdana, sans-serif;

NOTE:優(yōu)先使用靠前的字體

加粗字體

font-weight: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

font-weight: normal;
font-weight: bold;
傾斜字體

font-style: normal | italic | oblique | inherit

italic 使用字體中的斜體,而 oblique 在沒有斜體字體時強制傾斜字體。

更改行距

line-height: normal | <number> | <length> | <percentage>

normal 值為瀏覽器決定,在1.1至1.2之間(通常設置值為1.14左右)

/* length 類型 */
line-height: 40px;
line-height: 3em;
/* percentage 類型 */
line-height: 300%;
/* number 類型 */
line-height: 3;

NOTE:當line-heightnumber 類型時,子類直接繼承其數(shù)值(不計算直接繼承)。 而當為 percentage 類型時,子類則會先計算再顯示(先計算后繼承)。

字間距(字母間距)

letter-spacing: normal | <length>

其用于設置字間距或者字母間距,此屬性適用于中文或西文中的字母。 如果需要設置西文中詞與詞的間距或標簽直接的距離則需要使用 word-spacing。

word-spacing: normal | <length>

font shorthand

font: [ [ <‘font-style’> || <font-variant-css21> || <‘font-weight’> || <‘font-stretch’> ]? <‘font-size’> [ / <‘line-height’> ]? <‘font-family’> ] | caption | icon | menu | message-box | small-caption | status-bar

font: 30px/2 "Consolas", monospace;
font: italic bold 20px/1.5 arial, serif;
font: 20px arial, serif;

NOTE:當其他值為空時,均被設置為默認值。

改變文字顏色

color: <color>

element { color: red; }
element { color: #f00; }
element { color: #ff0000; }
element { color: rgb(255,0,0); }
element { color: rgb(100%, 0%, 0%); }
element { color: hsl(0, 100%, 50%); }

/* 50% translucent */
element { color: rgba(255, 0, 0, 0.5); }
element { color: hsla(0, 100%, 50%, 0.5); }

/* 全透明 */
element { color: transparent' }
element { color: rgba(0, 0, 0, 0); }

對齊方式

文字居中

text-align: start | end | left | right | center | justify | match-parent | start end

NOTE:默認為文本左對齊。

文本垂直對齊

vertical-align: baseline | sub | super | text-top | text-bottom | middle | top | bottom | <percentage> | <length>

NOTE:<percentage>的參照物為line-height

文本縮進

text-indent: <length> | <percentage> && [ hanging || each-line ]

NOTE:縮進兩個字可使用 text-indent: 2em;

格式處理

保留空格格式

white-space: normal | pre | nowrap | pre-wrap | pre-line

pre 行為同 <pre> 一致。

? New lines Spaces and tabs Text wrapping
normal Collapse Collapse Wrap
nowrap Collapse Collapse No wrap
pre Preserve Preserve No wrap
pre-wrap Preserve Preserve Wrap
pre-line Preserve Collapse Wrap
文字換行

word-wrap: normal | break-word

NOTE:允許長單詞自動換行。

word-break: normal | break-all | keep-all

NOTE:break-all 單詞中的任意字母間都可以換行。

文本裝飾

文字陰影

text-shadow:none | <shadow-t>#text-shadow:none | [<length>{2,3}&&<color>?]#

p {
  text-shadow: 1px 1px 1px #000,
               3px 3px 5px blue;
}
  1. value = The X-coordinate X 軸偏移像素
  2. value = The Y-coordinate Y 軸偏移像素
  3. value = The blur radius 陰影模糊半徑
  4. value = The color of the shadow 陰影顏色(默認為文字顏色)
文本裝飾(下劃線等)

text-decoration: <'text-decoration-line'> || <'text-decoration-style'> || <'text-decoration-color'>

h1.under {
    text-decoration: underline;
}
h1.over {
    text-decoration: overline;
}
p.line {
    text-decoration: line-through;
}
p.blink {
    text-decoration: blink;
}
a.none {
    text-decoration: none;
}
p.underover {
    text-decoration: underline overline;
}

高級設置

省略字符

text-overflow: [ clip | ellipsis | <string> ]{1,2}

/* 常用配合 */
text-overflow: ellipsis;
overflow: hidden; /* 溢出截取 */
white-space: nowrap; /* 禁止換行 */
更換鼠標形狀

cursor: [[<funciri>,]* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize| text | wait | help ]] | inherit

常用屬性

cursor: [<uri>,]*[auto | default | none | help | pointer | zoom-in | zoom-out | move]

  • <uri> 圖片資源地址代替鼠標默認形狀
  • <default> 默認光標
  • <none> 隱藏光標
  • <pointer> 手型光標
  • <zoom-in>
  • <zoom-out>
  • <move>
cursor: pointer;
cursor: url(image-name.cur), pointer;
/* 當 uri 失效時或者則會起作用 */
強制繼承

inherit 會強制繼承父元素的屬性值。

font-size: inherit;
font-family: inherit;
font-weight: inherit;
...
word-wrap: inherit;
work-break: inherit
text-showdow: inherit

NOTE:具體在使用時可查詢文檔

上一篇:接口設計下一篇:實體字符