样式表的基本语法
标签选择器:
input{
width:120px;
border:solid 1px #ff0000;
}
ID选择器:
#flow{color:#ff0000}
类选择器:
.center{
text-align:center;
font-weight:bold;
}
常见样式
课堂案例1:改变图片边框样式
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.sa{
border: 2px solid red;
}
.sb{}
</style>
<!-- <script type="text/javascript"> -->
<!--
<!--
<!--
<!--
<!--
<!--
<!--
<!--
<!--
</script>
</head>
<body>
<img onmouseleave="this.className='sb'" onmousemove="this.className='sa'" src="img/new_01.jpg" />
<img onmouseleave="this.className='sb'" onmousemove="this.className='sa'" src="img/new_02.jpg" />
<img onmouseleave="this.className='sb'" onmousemove="this.className='sa'" src="img/new_03.jpg" />
</body>
</html>
课堂案例2:使用className改变样式表
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
li{
font-size: 12px;
color: #FFFFFF;
background-image: url(img/bg1.gif);
background-repeat: no-repeat;
text-align: center;
height: 33px;
width: 104px;
line-height: 38px;
float: left;
list-style: none;
}
.out{
background-image: url(img/bg1.gif);
}
.over{
background-image: url(img/bg2.gif);
color: #ffff00;
font-weight: bold;
cursor: hand;
}
</style>
</head>
<body>
<ul>
<li onmousemove="this.className='over'" onmouseout="this.className='out'">资讯动态</li>
<li onmousemove="this.className='over'" onmouseout="this.className='out'">产品世界</li>
<li onmousemove="this.className='over'" onmouseout="this.className='out'">市场营销</li>
</ul>
</body>
</html>
课堂案例3:使用style改变样式表
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
li{
font-size: 12px;
color: #ffffff;
background-image: url(img/bg1.gif);
background-repeat: no-repeat;
text-align: center;
height: 33px;
width: 104px;
line-height: 38px;
float: left;
list-style: none;
}
</style>
</head>
<body>
<ul>
<li onmouseover="this.style.backgroundImage='url(images/bg2.gif)'" onmouseout="this.style.backgroundImage='url(images/bg1.gif)'">资讯动态</li>
<li onmouseover="this.style.backgroundImage='url(images/bg2.gif)'" onmouseout="this.style.backgroundImage='url(images/bg1.gif)'">产品世界</li>
<li onmouseover="this.style.backgroundImage='url(images/bg2.gif)'" onmouseout="this.style.backgroundImage='url(images/bg1.gif)'">市场营销</li>
</ul>
</body>
</html>`