HTML_CSS学习:常用文本属性

news/2024/9/23 11:54:12/
htmledit_views">

一、文本颜色

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>文本颜色</title><style>div{font-size: 90px;}.atguigu1{color: #238c20;}.atguigu2{color: rgb(255,0,0);}.atguigu3{color: rgba(0,255,0,0.5);}.atguigu4{color: #0000ff;}.atguigu5{color: #0000ff88;}.atguigu6{color: hsl(0,100%,50%);}.atguigu7{color: hsla(0,100%,50%,0.5);background-color: orange;}/*属性名:color*//*可选值:*//*1.颜色值*//* 2.rgb或rgba*//*  3.HEX或HEXA*//*   4.HSL或HSLA*//*    开发中常用的是 rgb/rgba  或HEX\HEXA(十六进制)*/</style>
</head>
<body><div class="atguigu1">尚硅谷1</div><div class="atguigu2">尚硅谷2</div><div class="atguigu3">尚硅谷3</div><div class="atguigu4">尚硅谷4</div><div class="atguigu5">尚硅谷5</div><div class="atguigu6">尚硅谷6</div><div class="atguigu7">尚硅谷7</div></body>
</html>

显示结果:

二、文本间距

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>文本间距</title><style>div{font-size: 30px;}.atguigu2{/*字符间距*/letter-spacing: 20px;}.atguigu3{/*单词之间的间距*/word-spacing: 20px;}</style>
</head>
<body><div>The knowledge points of the article.尚硅谷1</div><div class="atguigu2">The knowledge points of the article.尚硅谷2</div><div class="atguigu3">The knowledge points of the article.尚硅谷3</div></body>
</html>

显示结果:

三、文本修饰

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>文本修饰</title><style>div{font-size: 40px;}.atguigu1{/*上划的虚线*/text-decoration: overline dotted greenyellow;/*属性没有顺序要求*/}.atguigu2{/*text-decoration: underline dotted;*//*下划的波浪线*/text-decoration: underline wavy red;}.atguigu3{/*删除线*/text-decoration: line-through;}/*.atguigu4{*//*    text-decoration: none;*//*}*/.atguigu4,ins,del{/*没有各种线*/font-size: 40px;text-decoration: none;}</style>
</head>
<body><div class="atguigu1">尚硅谷1</div><div class="atguigu2">尚硅谷2</div><div class="atguigu3">尚硅谷3</div><a class="atguigu4" href="https://www.baidu.com">尚硅谷4</a><br><ins>测试1</ins><br><del>测试2</del></body>
</html>

显示结果:

四、文本缩进

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>文本缩进</title><style>div{font-size: 60px;text-indent: 120px ;}</style>
</head>
<body><div>欢迎来到信阳农林学院!欢迎来到信阳农林学院!欢迎来到信阳农林学院!欢迎来到信阳农林学院!</div></body>
</html>

显示结果:

五、文本对齐_水平

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>文本对齐</title><style>div{font-size: 40px;background-color: orange;/*text-align: left;*/text-align: center;/*文本对齐_水平*//*常用值:*//*1.left:左对齐*//*2.right:右对齐*//*3.center:居中对齐*/}</style>
</head>
<body><div>尚硅谷</div></body>
</html>

显示结果:

六、细说font-size

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>细说font-size</title><style>div{font-size: 40px;}/*由于字体设计原因,文字最终呈现的大小,并不一定与font-size的值一致,可能大,也可能小*//*例如:font-size设为40px,最终呈现的文字,可能比40px大,也可能比40px小*//*通常情况下,文字相对字体设计框,并不是垂直居中的,通常靠下一点*/</style>
</head>
<body><div>atguigu尚硅谷</div><br><span style="font-size: 40px;font-family: '微软雅黑';">尚</span><br><span style="font-size: 40px;font-family: 隶书;">尚</span><br><span style="font-size: 40px;font-family: 楷书;">尚</span></body>
</html>

显示结果:

七、行高

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>行高</title><style>#d1{font-size: 20px;background-color: #999ff0;line-height: 20px;/*第一种写法,值为像素*//*line-height:40px;*//*第二种写法,值为normal*//*line-height:normal;*//*font-family: "隶书";*//*第三种写法:值为数值*/line-height: 1.5;/*1相当于1.5*40px 相当于写的60px*//*第四种写法:值为百分比*/line-height: 150%;}/*由于字体设计原因,文字在一行中,并不是绝对垂直居中,若一行中都是文字,不会影响观感*/</style>
</head>
<body><div id="d1">atguigu尚硅谷让天下没有难掉的头发</div></body>
</html>

显示结果:

八、行高注意事项

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>行高注意事项</title><style>/*注意点1:行高过小会怎样?--文字重叠,且最小值是0,不能为负数*/#d1{font-size: 40px;background-color: #999ff0;line-height: 0;}/*注意点2:行高是可以继承的*/#d2{font-size: 40px;background-color: #37d2a6;line-height: 1.5;}span{font-size: 200px;color: yellow;}/*注意点3:line-height和height是什么关系*//*设置了height,高度就是height的值*//*没有设置height,高度就是line-height*行数*/#d3{font-size: 40px;background-color: #be6f0e;line-height: 100px;/*height: 300px;*/}#d4{font-size: 40px;background-color: skyblue;line-height: 0px;}/*行高的应用场景1:调整多行文字的间距*/#d5{font-size: 40px;background-color: salmon;line-height: 100px;}/*行高的应用场景2:单行文字的垂直居中  height等于line-height*/#d6{font-size: 40px;background-color: #0ebe90;height: 300px;line-height: 300px;}</style>
</head>
<body>
<!--    <div id="d1">atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发</div>-->
<!--    <div id="d2">atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu<span>尚硅谷</span>让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发</div>-->
<!--    <div id="d3">atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发vatguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发</div>-->
<!--    <div id="d4">atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发vatguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发</div>-->
<!--    <div id="d5">atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发vatguigu尚硅谷让天下没有难掉的头发atguigu尚硅谷让天下没有难掉的头发</div>--><div id="d6">atguigu尚硅谷让天下没有难掉的头发</div></body>
</html>

显示结果:

九、文本对齐_垂直

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>文本对齐_垂直</title><style>div{font-size: 40px;height: 400px;line-height: 760px;background-color: skyblue;font-family: "华文隶书";/*顶部:无需任何属性,在垂直方向上,默认就是顶部对齐*//*居中:对于单行文字,让height=line-height即可*//*底部:对于单行文字,目前一个临时的方式:*//*让line-height=(heightx2) - font-size - x*/}</style>
</head>
<body><div>尚硅谷</div></body>
</html>

显示结果:

十、vertical-align

相关代码:

html"><!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>vertical-align</title><style>div{font-size: 100px;height: 300px;background-color: #999ff0;}span{font-size: 40px;background-color: orange;/*vertical-align: top;*//*vertical-align: bottom;*/vertical-align: middle;}/*img{*//*    height: 30px;*//*    !*vertical-align: top;*!*//*    !*vertical-align: bottom;*!*//*    vertical-align: middle;*//*}*/img{height: 50px;vertical-align: bottom;/*图片在动:由最高的哪一个决定,图片的高度较高*/}.san{vertical-align: middle;}/*.test1{*//*    width: 400px;*//*    height: 400px;*//*    background-color: #0dcaf0;*//*}*//*.test2{*//*    width: 100px;*//*    height: 100px;*//*    background-color: #0ebe90;*//*    vertical-align: bottom;*//*}*//*反例:text*//*.test{*//*    width: 400px;*//*    height: 400px;*//*    background-color: green;*//*    vertical-align: middle;*//*}*/</style>
</head>
<body><div>atguigu尚硅谷x<span>x前端</span></div><hr><div>atguigu尚硅谷x<img src="../pictures/喜羊羊.jpg"></div><hr>
<!--    <div class="test">123</div>-->
<!--    <div class="test1">-->
<!--        <div class="test2"></div>-->
<!--    </div>--><table border="1"cellspacing="0"><caption>人员信息</caption><thead><tr><th>姓名</th><th>年龄</th><th>性别</th></tr></thead><tbody><tr height="200">
<!--                <td valign="bottom">张三</td>--><td class="san">张三</td><td>18</td><td>男</td></tr><tr><td>李四</td><td>20</td><td>女</td></tr></tbody></table></body>
</html>

显示结果:


http://www.ppmy.cn/news/1452391.html

相关文章

CUDA CPP Unity Compute Shader

为学 开始一个新的学习计划&#xff0c;涵盖&#xff1a; 主题学习内容CUDAProfessional CUDA C Programming/NVIDIA CUDA初级教程视频(周斌)CCPrimer / The Cherno CPPUnity Compute ShaderUdemy Learn to Write Unity Compute ShadersLinear AlgebraMIT 18.06 Prof.Gilbert…

【C语言】用数组和函数实现扫雷游戏

用数组和函数实现扫雷游戏 游戏界面&#xff1a; 代码如下&#xff1a; game.h #pragma once #include <stdio.h> #include <stdlib.h> #include <time.h> #define EASY_COUNT 10 #define ROW 9 #define COL 9 #define ROWS ROW2 #define COLS COL2 //初始…

经典网络解读——Efficientnet

论文&#xff1a;EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks&#xff08;2019.5&#xff09; 作者&#xff1a;Mingxing Tan, Quoc V. Le 链接&#xff1a;https://arxiv.org/abs/1905.11946 代码&#xff1a;https://github.com/tensorflow/t…

【C++】滑动窗口:最大连续1的个数

1.题目 2.算法思路 其实在做这道题的时候并不需要真的把0翻转成1&#xff0c;只需要找到最长的子数组且该子数组中0的个数不大于K&#xff0c;就可以了&#xff01; 当然我们首先想到的是暴力穷举法&#xff1a; 找到所有符合题意的子数组&#xff0c;跳出最长的那个就可以了…

WAAP动态安全解决方案

随着企业数字化进程不断加速&#xff0c;应用安全面临多重威胁&#xff0c;新型攻击方式层出不穷&#xff0c;常见的攻击形式包括Web应用攻击、DDoS攻击、API攻击、恶意爬虫攻击等。企业正面临严峻的安全防护挑战&#xff0c;需寻找一个可靠、全面的安全解决方案。在此情况下&a…

407. 接雨水 II

Problem: 407. 接雨水 II 文章目录 思路解题方法复杂度Code 思路 这个问题可以使用优先队列和广度优先搜索&#xff08;BFS&#xff09;来解决。首先&#xff0c;我们将所有边界上的单元格添加到优先队列中&#xff0c;并将其标记为已访问。然后&#xff0c;我们从队列中取出最…

FPGA搭积木之边沿检测电路

目录 1前言2.原理3.代码4仿真 1前言 今天分享一个FPGA设计中很常用的边沿检测电路&#xff0c;并参数化封装成自己的IP核。该电路的作用是输入一个信号&#xff0c;在其上升沿或者下降沿时&#xff08;可选&#xff09;输出一个时钟周期脉冲。时序图如下&#xff1a; 2.原理 利…

SSM整合-前后端分离-项目环境搭建 (上)

整合SSM 项目基础环境搭建项目介绍创建项目项目全局配置web.xmlSpringMVC配置配置Spring和MyBatis, 并完成整合创建表, 使用逆向工程生成Bean, XxxMapper和XxxMapper.xml注意事项和细节说明 实现功能01-搭建Vue前端工程需求分析/图解代码实现搭建Vue前端工程vue3项目目录结构梳…