css-----层叠样式表

内嵌式

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                   "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
   <title>使用CSS内嵌式</title>
   <style type="text/css">  /*声明优先加载和解析css代码*/
   /*定义标题标记居中对齐*/ 
   h2{ text-align:center;}   
   /*定义div标记样式色*/
   div{ border: 1px solid red; width: 300px;  height: 80px; color:blue; }       
   </style>
  </head>
  <body>
      <h2>内嵌式CSS样式</h2>
      <div>
 	 使用style标记可定义内嵌式CSS样式表,style标记一般位于head头部标记中,
 	 title标记之后。
      </div>
  </body>
</html>

嵌入式 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                   "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
      <title>使用链入式CSS样式表</title>
      <link href="style.css" type="text/css" rel="stylesheet" />
 </head>
 <body>
   <h2>内嵌式CSS样式</h2>
   <div>
 	使用style标记可定义内嵌式CSS样式表,style标记一般位于head头部标记中,
 	title标记之后。
   </div>
 </body>
</html>

css选择器和常用属性

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>选择器</title>
<style type="text/css">
/* 1.类选择器的定义*/
.red {
	color: red;
}
.green {
	color: green;
}
.font18 {
	font-size: 18px;
}
/* 2.id选择器的定义*/
#bold {
	font-weight: bold;
}
#font24 {
	font-size: 24px;
}
</style>
</head>
<body>
	<!--类选择器的使用-->
	<h1 class="red">标题一:class="red",设置文字为红色。</h1>
	<p class="green font18">
        段落一: class="green font18",设置文字为绿色,字号为18px。
     </p>
	<p class="red font18">
        段落二: class="red font18",设置文字为红色,字号为18px。
     </p>
	<!--id选择器的使用-->
	<p id="bold">段落1:id="bold",设置粗体文字。</p>
	<p id="font24">段落2:id="font24",设置字号为24px。</p>
	<p id="font24">段落3:id="font24",设置字号为24px。</p>
	<p id="bold font24">段落4:id="bold font24",同时设置粗体和字号24px。</p>
</body>
</html>

l

另有标记选择器:<bodey><h1><a>.通配符选择器:*{}

css常用属性

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值