web前台入门到实战:css常用样式font控制字体的多种变换

作者 : 开心源码 本文共2437个字,预计阅读时间需要7分钟 发布时间: 2022-05-13 共217人阅读

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/

专门建立的学习Q-q-u-n: 784783012 ,分享学习的方法和需要注意的小细节,不停升级最新的教程和学习技巧(从零基础开始到前台项目实战教程,学习工具,全栈开发学习路线以及规划) 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4     <meta charset="UTF-8"> 5     <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6     <title>css常用样式font字体的多种变换</title> 7     <style> 8         div{ 9             font-family: 'Microsoft YaHei';/*微软雅黑*/10             /* font-family: 'Lucida Sans','Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif; */11             /*字体加上双引号或者者单引号,当有多个字体的时候,中间逗号分开*/12             color:#f90;13             font-size: 24px;/*控制字体大小*/14             font-weight: bold;/*控制字重 常用lighter(细体) normal(正常)bold加粗 */15             font-style: italic;/*等同于em*/16             line-height: 30px;17         }18         /*font字体的简写:font:style weight size/line-heigt font-family*/19         /*要求必需出现的2个是 size font-family*/20         p{  21             font: 24px/1.5em 'Lucida Sans','Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;22             letter-spacing: 1px;/*英文字母间距*/23             word-spacing: 10px;/*英文单词间距*/24         }25         P::first-letter{26             text-transform: capitalize;27         }/*第一个字母::first-letter*/28         p::first-line{29             color:red;30         }/*第一行::first-line*/31     </style>32 </head>33 <body>34     <div>技术为王世界,欲问青天山顶景色能否独好技术为王世界,欲问青天山顶景色能否独好技术为王世界,欲问青天山顶景色能否独好技术为王世界, 35 欲问青天山顶景色能否独好技术为王世界,欲问青天山顶景色能否独好技术为王世界,欲问青天山顶景色能否独好技术为王世界, 36         欲问青天山顶景色能否独好技术为王世界,欲问青天山顶景色能否独好 </div>37     <p>Technology is king world, I want to ask if the scenery on the top of Qingtian Mountain is the king of technology, 38 I want to ask whether the scenery of Qingtian Peak is the king of technology. If the technology is the king of the world, 39         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>40 </body>41 </html>

关于样式继承问题/与文字有关样式会被继承下去/代码展现如下:

 1 <!doctype html> 2 <html lang="en"> 3 <head> 4     <meta charset="UTF-8"> 5     <title>index</title> 6     <style> 7         p{ 8             font-size: 20px; 9             font-family: 微软雅黑;    10             color:#f00;11             font-weight:bold;12             font-style:italic;13             word-spacing:15px;14         }15 16     </style>17 </head>18 <body>19     <div>20         <p><span>linux php linux</span></p>21         <p><span>linux linux php linux</span></p>22         <p><span>linux linux php linux</span></p>23         <p><span>linux linux php linux</span></p>24     </div>    25 </body>26 </html>
说明
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » web前台入门到实战:css常用样式font控制字体的多种变换

发表回复