CSS-选择器

基本选择器

  1. 标记选择器:

 

<style> h1 { /* h1为选择器 */ color: red; /* color为属性,red为属性值*/ font-size: 30px; /* font-size为属性,30px为属性值*/ } </style>
  1. id选择器: id 选择器以 "#" 来定义

#red {color:red;} -----id选择器只能出现一次,具有唯一性。

  1. 类选择器:类选择器以一个点 . 号显示
<style> p.center { 
text-align:center;
 }
</style>
</head> 
<body> 
<h1 class="center">这个标题不受影响</h1> -------样式前面整体是p.center
<p class="center">这个段落居中对齐。</p> 
</body>

<style>
 .center {
 text-align:center; 
} 
.color { 
color:#ff0000; 
} 
</style> 
</head> 
<body> 
<h1 class="center">标题居中</h1> --------有样式是center 
<p class="center color">段落居中,颜色为红色。</p> --------样式center和color叠加

 

基本选择器:

关系选择器:

属性选择器:

结构伪类选择器:

伪元素选择器:

当选择器发生冲突时:

内嵌式:

<style> 
p{
 background-color: pink; 
color: white; 
text-decoration: underline;
 font-weight: bold; 
font-size: 35px; 
} </style> 
</head> 
<body> 
<p>这是一个实验文件</p> 
<p>这是二个实验文件</p>
<p>这是三个实验文件</p>
</body>

链接式(绝对路径,相对路径)?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值