0
点赞
收藏
分享

微信扫一扫

css 基础语法

Villagers 2022-11-18 阅读 85


CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明。
css外部表

<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

选择器

selector {declaration1; declaration2; ... declarationN }

body {
color: #000;
background: #fff;
margin: 0;
padding: 0;
font-family: Georgia, Palatino, serif;
}

id 选择器

id 选择器可以为标有特定 id 的 HTML 元素指定特定的样式。
id 选择器以 “#” 来定义

#red {color:red;}
#green {color:green;}

<p id="red">这个段落是红色。</p>
<p id="green">这个段落是绿色。</p>

CSS 类选择器

.center {text-align: center}

<h1 class="center">
This heading will be center-aligned
</h1>

<p class="center">
This paragraph will also be center-aligned.
</p>


举报

相关推荐

css基础语法

CSS基础语法与盒模型

常用css 语法

CSS基本语法

CSS基本语法格式

CSS导读 (Emmet语法)

0 条评论