[转载]应用CSS[4] Text 文本——翻译Htmldog

一系列属性可以改变网页文字的大小和形状,概要如下:

font-family

文字使用的字体,比如宋体,Times New Roman,Arial等等

这个属性必须详细制定,不能使用偏僻的字体,要使用安全字体(比如arial,verdana和times new roman和宋体),可以同时指定许多字体,只要使用逗号分开即可。这样的用意是,如果用户电脑里没有第一个字体浏览器可以使用后面指定的字体。这非常有用,因为不同的电脑拥有不同的字体。例子font-size: arial,helvetica,pc用户可以使用arial而苹果mac用户可以使用helvetica。

注意:如果字体的名称有许多单词组成,使用双引号组合,比如,font-family: "Times New Romes"。

font-size

字体的大小,要小心使用。比如标题不会和段落一样,它要用大字体,你可以使用h1h2等等。

font-weight

这个属性决定字体是否加粗。在实际运用中通常使用font-weight: boldfont-weight: normal。理论上还可以使用bolder,lighter,100,200, 300, 400, 500, 600, 700, 800 or 900,但有些浏览器不认,仍坚持boldnormal

font-style

这个属性决定字体是否是斜体,可能是font-style: italicfont-style: normal

text-decoration

这个属性决定是文本否需要下划线。可以是:

  • text-decoration: overline,加上划线
  • text-decoration: line-through,加通过文本的线条。
  • text-decoration:underline,这应该使用在链接上,因为用户习惯认为它代表链接。

text-transform

改变文本的情况。

  • text-transform: capitalize ,让每个字的第一个字母大写。
  • text-transform: uppercase ,所有大写。
  • text-transform: lowercase,所有小写。
  • text-transform: none; ,这个属性不起作用。
    
    body {
    	font-family: arial, helvetica, sans-serif;
    	font-size: 0.8em;
    }
    
    h1 {
    	font-size: 2em;
    }
    
    h2 {
    	font-size: 1.5em;
    
    }
    
    a {
    	text-decoration: none;
    }
    
    strong {
    	font-style: italic;
    	text-transform: uppercase;
    }
    

    Text spacing

    letter-spacingword-spacing属性的意思是字母和文字之间的间隔。值可以是长度或normal

    line-height属性设定元素的行高,比如一个段落,没有调准字体的大小。它可以是数字(字体大小的倍数),长度,百分比或normal

    text-align设定元素位置,left,right,centerjustify

    text-indent属性缩进段落的首行。这在打印时经常设置,但网页里通常用不上。

    
    p {
    	letter-spacing: 0.5em;
    	word-spacing: 2em;
    
    	line-height: 1.5;
    	text-align: center;
    }
     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值