前端css(2)

我们网站中用到最多的就是文字,那么对于文字的样式设置就显得尤为重要。今天我们就来讲一些文字设置相关的css。

字体设置

复制代码
<html>
    <head>
        <title>css</title>
    </head>
    <body>
        <div style="font-family: 'Times New Roman',Times, serif;">字体1</div>
        <div style="font-family:Arial,Helvetica,sans-serif;">字体2</div>
        <div style="font-style:italic">斜体</div>
        <div style="font-size: 50px;">字体大小</div>
        <div style="font-weight: bold;">粗体</div>
        <div style="font-weight: lighter;">细体</div>
        <div style="font-weight: normal;">正常大小</div>
    </body>
</html>

注:

font-family:用来设置字体,后面可以写多个字体,当第一个不支持的时候会使用第二个;

font-style:指定字体的样式,斜体或正常体;

font-size:设置字体的大小;

font-weight:设置字体的粗细;

颜色设置

复制代码
<html>
    <head>
        <title>css</title>
    </head>
    <body>
        <div style="color: red;">颜色1</div>
        <div style="color: rgb(155,111,98);">颜色2</div>
    </body>
</html>

注:字体颜色使用color进行设置,后面可以写对应的颜色的英语;或者使用rgb或rgba来进行设置。

字体对齐

复制代码
<html>
    <head>
        <title>css</title>
    </head>
    <body>
        <div style="text-align: left;">左对齐</div>
        <div style="text-align: center;">居中对齐</div>
        <div style="text-align: right;">右对齐</div>
    </body>
</html>

注:字体的对齐使用text-align:left;center,right来进行设置。

行高设置

复制代码
<html>
    <head>
        <title>css</title>
    </head>
    <body>
        <div style="line-height: 50px;">行高1</div>
        <div style="line-height: 20px;">行高2</div>
        <div style="line-height: 5px;">行高3</div>
    </body>
</html>

注:行高line-height用来设置文本的高度。

相关推荐
Csvn4 分钟前
性能监控
前端
Csvn30 分钟前
构建工具
前端
FRing031 小时前
vue2干货总结3(computed计算属性、watch监听器)
开发语言·前端·vue.js·vue2
kyriewen3 小时前
Skills 榜前 10 我全装了:只有 3 个能直接用
前端·javascript·程序员
IT_陈寒3 小时前
当Java的hashCode遇上Lombok,我的缓存被全清了
前端·人工智能·后端
工控丫丫4 小时前
帆软看板中经常使用的公式函数及经常搭的组合
前端·javascript·数据库
jerrywus4 小时前
我用 GPT-6.1-sol 做了台会讲解的 3D 售货机:60 罐饮料,一口没喝上
前端·agent·claude
孟陬6 小时前
Foobar 技术周刊#159:当看不懂代码时,如何高效排障调试。脏页陷阱:一条只读查询,写入数 TB 数据。推测解码:大模型加速利器
前端·人工智能·后端
Zhao-Jichao6 小时前
AI Prompting for Everyone 课程笔记 - P17 图像生成 Imaging Generation
前端
Highcharts.js6 小时前
智能数据分析组件Orbit 正式发布与快速上手体验教程
前端·人工智能·信息可视化·数据分析系统·highcharts·orbit·智能可视化