前端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用来设置文本的高度。

相关推荐
2501_943782359 分钟前
【共创季稿事节】猜数字游戏:二分法思维与交互式反馈
前端·游戏·microsoft·harmonyos·鸿蒙·鸿蒙系统
GV191rLvq23 分钟前
基于Socket实现的最简单的Web服务器【ASP.NET原理分析】
服务器·前端·asp.net
吠品29 分钟前
LangChain 里 tool_call_id 为空?一次 MCP 工具集成的排查记录
前端
柒和远方1 小时前
Phase 7.4 学习博客:为什么多 API 项目需要 Swagger / OpenAPI
前端·后端·架构
张龙6871 小时前
拼多多开放平台对接踩坑实录:从 CLIENT_ID 配置到 MD5 签名算法的完整填坑指南
前端
GuWenyue1 小时前
提示词彻底过时?一套上下文工程方案,3步让LLM落地生产,代码直接复用
前端·javascript·人工智能
柒和远方1 小时前
Phase 7.3 复盘:后台任务不只是“扔进队列”,还要能被看见
前端·后端·架构
2501_943782351 小时前
【共创季稿事节】 倒计时器:时分秒选择器与定时器的协同工作
前端·华为·harmonyos·鸿蒙·鸿蒙系统
奶油mm1 小时前
公司技术债堆积如山,我一人之力用 Vue3 偷换了整个前端架构
前端·vue.js
用户938515635071 小时前
深入理解 JavaScript 中的 this 与数据存储的奥秘
前端·javascript