CSS基础教程之尺寸、字体及文... 登录

CSS基础教程之尺寸、字体及文本属性

CSS尺寸属性

  • width:元素宽度,一定要加px单位。

  • height:元素高度。


CSS字体属性

  • font-size:文字大小。如:font-size:14px;

  • font-family:字体。如:font-family:微软雅黑;

  • font-style:斜体,取值:italic。如:font-style:italic;

  • font-weight:粗体,取值:bold。如:font-weight:bold;


CSS文本属性

  • color:文本颜色

  • text-decoration:文本修饰线,取值:none(无)、underline(下划线)、overline(上划线)、line-through(删除线)

  • text-align:文本水平对齐方式,取值:left、center、right

  • line-height:行高,可以用固定值,也可以用百分比。如:line-height:24px;   line-height:150%;

  • text-indent:首行缩进。如:text-indent:28px;

  • letter-spacing:字间距。

实例如下

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
    <style type="text/css">
    h1{
        color:red;
        width:350px;
        text-align:center;
        font-family:微软雅黑;
    }
    p{
         line-height:150%;
         text-indent:28px;
         font-family:楷体;
    }
    .box{
        font-style:italic;
        font-weight:bold;
        text-decoration:underline;
    }
    </style>
    </head>
    <body>
        <h1>习近平心中的互联网</h1>
        <p>互联网是20世纪最伟大的发明,它正在将人类“<span class="box">一网打尽</span>”,人们在不知不觉中已经融入了互联网生态,互联网让世界变成了“鸡犬之声相闻”的地球村。</p>
    </body>
</html>


下一节
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <style type="text/css"> h1{ color:red; width:350px; text-align:center; font-family:微软雅黑; } p{ line-height:150%; text-indent:28px; font-family:楷体; } .box{ font-style:italic; font-weight:bold; text-decoration:underline; } </style> </head> <body> <h1>习近平心中的互联网</h1> <p>互联网是20世纪最伟大的发明,它正在将人类“<span class="box">一网打尽</span>”,人们在不知不觉中已经融入了互联网生态,互联网让世界变成了“鸡犬之声相闻”的地球村。</p> </body> </html>
提交 重置代码
章节 评论 笔记 课件
  • 取消 回复 发送
  • 取消 发布笔记 发送