HTML学习笔记7——字体、文本样式,以及一点伪类语法

字体样式

设置字体的类型,风格,大小,粗细等

属性样式示例
font-family设置字体(宋体、楷体等设置电脑上有的字体)font-family:"隶书";
font-size字体大小(像素 px)font-size:12px;
font-style字体风格(倾斜、加粗等)font-style:italic;
font-weight字体加粗(100最细,900最粗)font-weight:bold;
font设置以上所有的属性(顺序 风格、加粗、大小、字体)font:italic bold 30px "宋体";
代码示例

html

<!DOCTYPE html>    
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文本装饰</title>
    <link rel="stylesheet" href="./222.css">     
    <!-- <style>
        @import url(./222.css);
    </style> -->
</head>
<body>
    <h1>相知于冬雪,风雨奕同周</h1>
    <p class="sqhy">向全世界安利最好的诗情画奕</p>
    <p class="sqhy">诗情画奕szd</p>
    <p id="kkk">4781</p>
    <p>我<span class="show">"是"</span>谁</p>
</body>
</html>

 css

h1{
    color:red;
    font-size: large;
    font-family: "楷体";
    font-weight: 800;   
}

.sqhy{
    color:brown;
    font-style: italic;
    font-family: "宋体";    
}

#kkk{
    color:blueviolet;
}
效果展示 

文本样式

属性含义示例
color设置文本颜色color:red; 颜色 红色
text-align设置元素水平对齐方式text-align: center; 水平居中
text-indent设置首行文本缩进text-indent: 2cap;
line-height设置文本行高line-height: 40px;
text-decoration设置文本装饰text-decoration: none; 无、取消下划线等装饰
代码示例
<!DOCTYPE html>    
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文本装饰</title>
    <link rel="stylesheet" href="./222.css">     
    <!-- <style>
        @import url(./222.css);
    </style> -->
    <style>
        p{
            text-align: center;  /*居中对齐*/
            height: 40px;
            width: 500px;
            background-color: aquamarine;  /*设置背景颜色*/
            line-height: 40px;  /*行高与前边的height相同就可以上下居中*/
            text-decoration: underline red;   /*文本装饰 红色下划线,默认与字体颜色一致*/
            text-decoration: none;
        }
        h6{
            background-color: aquamarine;
            height: 75px;
            width: 100px;
            text-indent: 2cap;  /*首行缩进*/
        }
    </style>
</head>
<body>
    <h1>相知于冬雪,风雨奕同周</h1>
    <p class="sqhy">向全世界安利最好的诗情画奕</p>
    <p class="sqhy">诗情画奕szd</p>
    <p id="kkk">4781</p>
    <p>我<span class="show">"是"</span>谁</p>
    <h6>巴拉巴拉巴拉巴拉额符合UI哦会哦反而赫然个不择然而8一般v尽快十点半儿童昂热二号</h6>
</body>
</html>
h1{
    color:red;
    font-size: large;
    font-family: "楷体";
    font-weight: 800;
    text-align: center;
    height: 40px;
    width: 500px;
    background-color: aquamarine;
    line-height: 40px;  /*行高与前边的height相同就可以上下居中*/
}

.sqhy{
    color:brown;
    font-style: italic;
    font-family: "宋体";
    text-align: center;
}

#kkk{
    color:blueviolet;
    text-align: center;
}
效果展示

伪类语法

标签名:伪类名{声明;}

a:hover{
	color:#B46210;
	text-decortaion:underline;
}

伪类

伪类名称含义
a:link未单击访问时超链接样式
a:visited单击访问后超链接样式
a:hover鼠标悬浮其上的超链接样式
a:active鼠标单击未释放的超链接样式

鼠标形状

说明
default默认光标
pointer超链接的指针
wait等待的效果
help指示可用的帮助
text指示文本
crosshair十字
代码示例
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>伪类语法</title>
    <style>
        /*单击访问后*/
        a:visited{           
            color: black;
            text-decoration: line-through;
            font-size: 40px;
        }
        /*鼠标悬浮其上*/
        a:hover{              
            color: aquamarine;
            text-decoration: overline;
            font-size: 40px;
            cursor: pointer;
        }
        /*鼠标单击未释放*/
        a:active{             
            color:aqua;
            text-decoration: underline;
            font-size: 40px;
        }
    </style>
</head>
<body>
    <a href="https://www.iqiyi.com/?vfm=f_588_wrb&fv=ac30238882b84c8c">点我跳转</a>
</body>
</html> 

效果不展示,自己挨个试就能理解了,上手操作还是更容易理解的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值