加入收藏 | 设为首页 | 会员中心 | 我要投稿 江门站长网 (https://www.0750zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 编程要点 > 语言 > 正文

CSS的font属性如何使用

发布时间:2023-12-27 18:00:09 所属栏目:语言 来源:DaWei
导读: 我们知道CSS的font属性是字体样式设置的一个属性,我们经常需要对字体样式进行操作,对此这篇就给大家来讲讲font属性的时候,以及使用需要注意的一些事项问题,文中的示例代码有一定的参
    我们知道CSS的font属性是字体样式设置的一个属性,我们经常需要对字体样式进行操作,对此这篇就给大家来讲讲font属性的时候,以及使用需要注意的一些事项问题,文中的示例代码有一定的参考价值,有需要的朋友可以了解看看。

    CSS 字体属性定义文本的字体系列、大小、加粗、风格(如斜体)和变形(如小型大写字母)font-family控制字体,由于各个电脑系统安装的字体不尽相同,但是基本装有黑体、宋体与微软雅黑这三款字体,通常这样写font-family:"黑体", "宋体","Microsoft YaHei"

    font-size控制字体大小,我们设置字体大小是设置它的宽度,它的高度一般电脑系统默认字体大小是16px,所以字体大小尽量不要低于16px,1em=16px; font-weight: bold;/*控制字重 一般是100-900 常用lighter(细体) normal(正常)bold加粗 */至于这个font-style,一般默认是normal,也就是正常的,如果说你设置 font-style: italic;斜体话,其实和这个<em></em>的效果是差不多的;文字间的间距用的line-height如果和高度相等话,就是垂直居中了。

    通常font字体的简写:font:style weight size/line-heigt font-family /*要求必须出现的2个是 size与font-family*/
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css常用样式font字体的多种变换</title>
    <style>
        div{
            font-family: 'Microsoft YaHei';/*微软雅黑*/
/* font-family: 'Lucida Sans','Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; */
            /*字体加上双引号或者单引号,当有多个字体的时候,中间逗号分开*/
            color:#f90;
            font-size: 24px;/*控制字体大小*/
            font-weight: bold;/*控制字重 常用lighter(细体) normal(正常)bold加粗 */
            font-style: italic;/*等同于em*/
            line-height: 30px;
        }
        /*font字体的简写:font:style weight size/line-heigt font-family*/
        /*要求必须出现的2个是 size font-family*/
        p{  
            font: 24px/1.5em 'Lucida Sans','Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
            letter-spacing: 1px;/*英文字母间距*/
            word-spacing: 10px;/*英文单词间距*/
        }
        P::first-letter{
            text-transform: capitalize;
        }/*第一个字母::first-letter*/
        p::first-line{
            color:red;
        }/*第一行::first-line*/
    </style>
</head>
<body>
    <p>Technology is king world, I want to ask if the scenery on the top of Qingtian Mountain is the king of technology, 
        I want to ask whether the scenery of Qingtian Peak is the king of technology. If the technology is the king of the world, 
        I would like to ask whether the scenery on the top of Qingtian Mountain is the king of the world. Is the scenery good?</p>
</body>
</html>

    对CSS的font属性的相关就介绍到这,上述示例具有一定的借鉴价值,感兴趣的朋友可以参考,希望能对大家学习font属性的使用有帮助,想要了解更多大家可以关注其它的相关文章。

(编辑:江门站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章