css入门基础01

一 基本语法

<head>
	<style>
		选择器{
     
			属性名:属性值;
			属性名:属性值;
		}
	</style>
</head>

二 基础选择器

2.1 常用选择器

在这里插入图片描述

2.2 案例

## 2.1 标签选择器

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        p{
     
            color: turquoise; 
        }
        .red {
     
            background-color: red;
            width: 100px;
            height: 100px;
        }
        .green {
     
            background-color: green;
            width: 100px;
            height: 100px;
        }
        #yellow20{
     
            font-size: 20px;
            color: yellow;
        }
        *{
     
            background-color: violet;
           
        }
    </style>
</head>

<body>
    <div class="red">
    </div>
    <div class="green">
    </div>
    <div class="red">
    </div>
    <p>
        这是标签选择器
    </p>
    <p>
        帅哥
    </p>
    <div id="yellow20">这是id选择器</div>
</body>

</html>

2.3 选择器优先级

!important>行内样式>ID选择器>类选择器>标签选择器>继承选择器

原因:首先加载标签选择器,再加载类选择器,然后加载ID选择器,最后加载行内样式后加载会覆盖先加载的同名样式

三 css属性

3.1 字体属性

3.1.1font-family 字体种类

<style>
p{
   
font-family:"微软雅黑";
}
</style>

3.1.2 font-size 字体大小

<style>
p{
   
font-size:20px;
}
</style>

3.1.3 font-weight 字体粗细

<style>
p{
   
/*值从100-900,400是正常大小,可写成normal*/
font-weight:400;
}
</style>

3.1.4 font-style 字体样式

<style>
em{
   
/*这是把em标签改为正常字体*/
font-style:normal;
}
p{
   
/* 字体倾斜 */
font-style: italic;
 }
</style>

3.1.5 字体样式的复合属性写法

<style>
      #z{
     
            /* font:font-style font-weight font-size font-family; */
            /* 四个属性顺序不能更换,且font-size和font-family是必须要有的属性*/
           font: normal 900 30px "微软雅黑";
        }
    </style>

3.2 文本属性

在这里插入图片描述

3.2.1 文本颜色color

颜色名称:使用英文单词
16进制的RGB值:#RRGGBB
rgb函数:rgb(red,green,blue)

3.2.2 对齐文本text-align

3.2.3 装饰文本text-decoration

3.2.4 文本缩进text-indent

在这里插入图片描述

3.2.5 行间距line-height

在这里插入图片描述
实例:
在这里插入图片描述

3.3 css引入方式

  • 内部样式表
  • 行内样式表
  • 外联样式表
    在这里插入图片描述
    在这里插入图片描述

3.4 emmet语法快速生成HTML语法结构

在这里插入图片描述
5.".demo+enter"自动生成

<div class="demo"></div>

"#demo+enter"自动生成

<div id="demo"></div>

6.“.demo$*5{自增} +enter ”自动生成

<div 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值