CSS的简单使用

添加的两种方式:

  1. 在HTML文档中直接定义
  2. 存为一个文件名是*.css
<HTML>
<HEAD>
<TITLE>CSS DEMO - 使用CSS 使用元素选择器</TITLE>
	<style>
		<!--
			h3 {
				font-family:Arial;
				font-style:italic;
				color:green;
			  }
			  h2{color:red}
                          p{color:red}
		-->
	</style>
	
</HEAD>
<BODY>
	<h3>This is a green,italic,Arial H3 header.</h3>
	<h2>This is another green,italic,Arial H3 header.</h3>
	  <P>
	  	这是正文 这是正文 这是正文
	  </P>
</BODY>
</HTML>
-----------------------------------------------
<html>
	<head>
		<title>id选择器示例</title>
		<style type="text/css">
      #myID {text-decoration:underline}
		</style>
	<head>
	<body>
	  <h3 id="myID">这是一个标题</h3>
	  <P>
	  	这是正文 这是正文 这是正文 
	  </P>
	  <P id="myID">
	  	这是正文 这是正文 这是正文
	  </P>
  </body>
<html>
-------------------------------------------------
<html>
	<head>
		<title>class选择器示例</title>
		<style type="text/css">
      .myID {text-decoration:underline}
      #myID {text-decoration:line-through}
		</style>
	<head>
	<body>
	  <h3 class="myID">这是一个标题</h3>
	  <P id="myID">
	  	这是正文 这是正文 
	  </P>
	  <P class="myID">
	  	这是正文 这是正文
	  </P>
  </body>
<html>
-----------------------------------------------
<html>
	<head>
		<title>后代选择器示例</title>
		<style type="text/css">
      <!--表示li标签中的b标签的格式-->
      li b{text-decoration:underline}
		</style>
	<head>
	<body>
		这是li外面<b>下划线</b>
	  <li>这是li里面<b>下划线</b></li>	  
  </body>
<html>

在head中的两种引用.ss文件的方法
<HTML>
<HEAD>
<TITLE>CSS 演示</TITLE>
	<link rel=stylesheet href="globalstyle.css" type="text/css">   
	<!--
	<style type="text/css">		
		@import url("globalstyle.css")
	</style>
	-->
</HEAD>


<BODY>
	<H1>Headline is blue</H1>

	<P style="color:green;font-size:72;">While the paragraph is green.
	</P>
	<a href="">hhh</a>

</BODY>
</HTML>
-----------------------------------------
globalstyle.css:
H1{color:blue}
		a:link {cursor:wait;text-decoration:none ;color:blue}
                a:hover {cursor:wait;text-decoration:underline;color:#C6EF4A}
                a:visited {cursor:wait;text-decoration:none;color:#F253F0}
                a:active {cursor:wait;text-decoration:none;color:#F253F0 }

设置背景颜色,字体颜色,背景图片

<HTML>
<HEAD>
	<TITLE>字体、背景颜色使用</TITLE>
		
		<style type="text/css">
		<!--
                        .bkcolor{background-color: #CCEFCC} 
			.greentext {color: green}
			.redtext {color: #FF0000}
			.bluetext {color: rgb(0,0,255)}
		-->	
		</style>
</HEAD>
<BODY>
	<p class="greentext">绿色文本</p>
	<p class="redtext">红色文本</p>
	<p class="bluetext">蓝色文本</p>
        <p class="bkcolor">绿色背景</p>
	aaa
</BODY>
</HTML>
------------------------------------------
<HTML>
<HEAD>
	<TITLE>利用CSS实现的网页背景图片</TITLE>
	<style type="text/css">
		<!--
			.bg-image{ background-image: url('1.gif') }
		-->
	</style>
</HEAD>
<BODY >
	<H1 class="bg-image" style="color:blue">
          CSS可以为没有背景属性的标记加上背景图        </H1>
</BODY>
</HTML>
---------------------------------------------
滤镜:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CSS滤镜特效</title>
<style type="text/css">
<!--
.wave {
	filter: Wave(Add=0, Freq=6, LightStrength=20, Phase=15, Strength=8);
}
-->
</style>
<style type="text/css">
<!--
.Xray {
	filter: Xray;
	;
}
.Shadow {
	filter: Shadow(Color=#666666, Direction=135);
}
-->
</style>
<style type="text/css">
<!--
.Gray {
	filter: Gray;
}
.Invert {
	filter: Invert;
}
.Chroma {
	filter: Chroma(Color=#0000FF);
}
.DropShadow {
	filter: DropShadow(Color=#cccccc, OffX=10, OffY=10, Positive=1);
}
.FlipH {
	filter: FlipH;
}
.FlipV {
	filter: FlipV;
}
.Alpha {
	filter: Alpha(Opacity=100, FinishOpacity=0, Style=2);
}
.Blur {
	filter: Blur(Add=0, Direction=1, Strength=8);
}
-->
</style>
</head>

<body>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr align="center"> 
    <td><img src="lion.jpg" width="160" height="194"></td>
    <td><img src="lion.jpg" width="160" height="194" class="Alpha"></td>
    <td><img src="lion.jpg" width="160" height="194" class="Blur"></td>
  </tr>
  <tr align="center"> 
    <td>原图</td>
    <td>Alpha滤镜</td>
    <td>Blur滤镜</td>
  </tr>
</table>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr align="center"> 
    <td><img src="bigcat1.gif" width="200" height="257" class="Chroma"></td>
    <td>
    <img src="bigcat.gif" width="200" height="257" class="DropShadow"></td>
  </tr>
  <tr align="center"> 
    <td>Chroma滤镜</td>
    <td>DropShadow滤镜</td>
  </tr>
  <tr align="center"> 
    <td><img src="bigcat.gif" width="200" height="257" class="FlipH"></td>
    <td><img src="bigcat.gif" width="200" height="257" class="FlipV"></td>
  </tr>
  <tr align="center"> 
    <td>FlipH滤镜<br> </td>
    <td>FlipV滤镜</td>
  </tr>
</table>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr align="center"> 
    <td><img src="cat.jpg" width="150" height="161"></td>
    <td><img src="cat.jpg" width="150" height="161" class="gray"></td>
    <td><img src="cat.jpg" width="150" height="161" class="invert"></td>
  </tr>
  <tr align="center"> 
    <td>原图</td>
    <td>Gray滤镜</td>
    <td>Invert滤镜</td>
  </tr>
</table>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="2" class="shadow">
  <tr align="center"> 
    <td><img src="pig.jpg" width="150" height="166" class="shadow"></td>
    <td><img src="pig.jpg" width="150" height="166" class="wave"></td>
    <td><img src="pig.jpg" width="150" height="166" class="Xray"></td>
  </tr>
  <tr align="center"> 
    <td>Shadow滤镜</td>
    <td>Wave滤镜</td>
    <td>Xray滤镜</td>
  </tr>
</table>
</body>
</html>

CSS鼠标形状:

<HTML>
<HEAD>
	<TITLE>鼠标形状演示</TITLE>
	<style type="text/css">
		<!--
			.hand{cursor:hand;}			/*手形*/
			.crosshair{cursor:crosshair;}	        /*精确定位“+”字*/
			.move{cursor:move;}			/*移动*/
			.e-resize{cursor:e-resize;}		/*箭头朝右方*/
			.ne-resize{cursor:ne-resize;}	        /*箭头朝右上方*/
			.nw-resize{cursor:nw-resize;}	        /*箭头朝左上方*/
			.n-resize{cursor:n-resize;}		/*箭头朝上方*/
			.se-resize{cursor:se-resize;}	        /*箭头朝右下方*/
			.s-resize{cursor:s-resize;}		/*箭头朝下方*/
			.w-resize{cursor:w-resize;}		/*箭头朝左方*/
			.text{cursor:text;}			/*“I”字型*/
			.wait{cursor:wait;}			/*等待*/
			.help{cursor:help;}			/*帮助*/
		-->
	</style>
</HEAD>
<BODY>
	<p class="hand">Give me a hand!(手形)</p>
	<p class="crosshair">Give me a crosshair(精确定位)!</p>
	<p class="move">Give me a Move(移动)!</p>
	<p class="e-resize">Give me a e-resize(箭头方向朝右)!</p>
	<p class="ne-resize">Give me a ne-resize(箭头方向朝右上)!</p>
	<p class="nw-resize">Give me a nw-resize(箭头方向朝左上)!</p>
	<p class="n-resize">Give me a n-resize(上)!</p>
	<p class="se-resize">Give me a se-resize(右下)!</p>
	<p class="s-resize">Give me a s-resize(下)!</p>
	<p class="w-resize">Give me a w-resize(左)!</p>
	<p class="text">Give me a text(文本)!</p>
	<p class="wait">Give me a wait(等待)!</p>
	<p class="help">Give me a help(帮助)!</p>
</BODY>
</HTML>

作业:

<html>
<head>
<title>CSS的演示</title>
<style type="text/css">

body {font-size: 12px;color: #FF00FF;}
a:link {font-size: 12px;color: #000000;text-decoration: underline;}
a:visited {font-size: 12px;font-weight: bold;color: #FF00FF;text-decoration: line-through;}
a:hover {font-size: 12px;font-weight: bold;color: #009900;text-decoration: overline;}
a:active {font-size: 12px;font-weight: bolder;color: #FF3300;text-decoration: line-through;}
.aaa {font-size: 24px;color: #FF0000;text-decoration: underline;}

</style>
</head>
<body>
<p class="aaa">百纳欢迎您的到来!</p>
<p>今天的投入,明天的回报!</p>
<p><a href="0917.htm">百纳欢迎您的到来!</a></p>
<p>今天的投入,明天的回报!</p>
<p>百纳欢迎您的到来!</p>
<p>今天的投入,明天的回报!</p>
<EMBED src=kissbye.mid width=145 height=60 autostart=True loop=True></EMBDE>
<video controls loop height=600px width=600px>
<source src="案例视频.mp4">
</video>
</body>
</html>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值