CSS文本样式

字体

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

font-size:2em
font-size:200%
//以父元素的字体大小作为参照物

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

body { font-family: helvetica, verdana, sans-serif; }
//可以用逗号分隔设置多个字体

font-weight:normal | bold | bolder | lighter | <integer>
<integer>: 用数字表示文本字体粗细。取值范围:100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

body { font-weight:blod; }

font-style:normal | italic | oblique
normal: 指定文本字体样式为正常的字体
italic: 指定文本字体样式为斜体。对于没有设计斜体的特殊字体,如果要使用斜体外观将应用oblique
oblique: 指定文本字体样式为倾斜的字体。人为的使文字倾斜,而不是去选取字体中的斜体字

body{font-style:normal}

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

line-height:3em;
line-height:300%;//子元素继承计算后的值
line-height:3;//子元素直接继承

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

font:italic bold 20px/1.5 arial,serif
// <' font-size '> 和 <' font-family '> 是不可忽略的。 

color:red 设置字体颜色

对齐方式

  • 水平对齐

text-align:left | right | center | justify
样式可继承

  • 垂直对齐

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

  • 首行缩进

text-indent:[ <length> | <percentage> ]

格式处理

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

换行符 空格和tabs 是否自动换行
normal 合并 合并
nowrap 合并 合并
pre 不合并 不合并
pre-wrap 不合并 不合并
pre-line 不合并 合并

word-wrap:normal | break-word 允许长单词自动环行

word-break:normal | keep-all | break-all 允许单词内环行

文本修饰

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

text-shadow:1px 2px 3px #f00
x轴偏移、y轴偏移、阴影模糊半径;color默认是文字颜色

text-decoration:none | underline | overline | line-through | blink

高级修饰

文字溢出显示

text-overflow:clip | ellipsis
ellipsis: 当内联内容溢出块容器时,将溢出部分替换为(...)。
跟white-space:nowrap;overflow:hidden;配合使用

鼠标形状

cursor::[<url> [<x> <y>]?,]*[ auto | default | none | help | pointer | zoom-in | zoom-out | move ]

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • CSS提供了几个属性来操作字体。font,可以很方便的指定字体的属性。比如: 字体加粗,字体的风格:斜体和字体变形...
    勿以浮沙筑高台阅读 337评论 0 0
  • 1.块级元素和行内元素 块级(block-level)元素;行内(内联、inline-level)元素。 块元素的...
    饥人谷_小侯阅读 2,079评论 1 4
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    wzhiq896阅读 1,830评论 0 2
  • 1.CSS简介 Cascading Style Sheet 层叠样式表 主要用来定义页面中的表现,HTML 描述页...
    hyt222阅读 899评论 0 0
  • 于我而言 2015是一个多风的年头吧 但不知在何时何地 突然就凌乱在风里了呢 凌乱了又何妨呢? 我愿就此凌乱 继续...
    小贺无心阅读 247评论 0 1