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

相关推荐
贼爱学习的小黄17 分钟前
NC BIP参照开发
java·前端·nc
小江的记录本21 分钟前
【MyBatis-Plus】MyBatis-Plus的核心特性、条件构造器、分页插件、乐观锁插件
java·前端·spring boot·后端·sql·tomcat·mybatis
光影少年26 分钟前
如何进行前端性能优化?
前端·性能优化
Dxy123931021632 分钟前
js如何把字符串转数字
开发语言·前端·javascript
爱写bug的野原新之助41 分钟前
爬虫之补环境:加载原型链
前端·javascript·爬虫
陈广亮1 小时前
工具指南7-Unix时间戳转换工具
前端
NGBQ121381 小时前
Adobe-Premiere-Pro-2026-26.0.2.2-m0nkrus 全解析:专业视频编辑软件深度指南
前端·adobe·音视频
北城笑笑1 小时前
Chrome:Paused in debugger 的踩坑实录:问题排查全过程与终极解决方案( 在调试器中暂停 )
前端·chrome
haorooms1 小时前
Promise.try () 完全指南
前端·javascript
kyriewen1 小时前
闭包:那个“赖着不走”的家伙,到底有什么用?
前端·javascript·ecmascript 6