目录
1.回顾样式表
1.1 样式表的基本语法
标签选择器
input{
width:120px;
border:solid 1px #ff0000;
}
ID选择器
#flow{color:#ff0000}
类选择器
.center{
text-align:center;
font-weight:bold;
}
1.2 常见样式
1.3 样式表类型
行内样式
内部样式表
外部样式表
2.改变图片边框样式
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
/* 改变图片边框 */
.sa{
border: 2px solid red;
}
/* 恢复图片边框 */
.sb{}
</style>
<!-- <script type="text/javascript"> -->
<!-- // // 改变图片边框 -->
<!-- // function changeImage(obj){ -->
<!-- // obj.className="sa"; -->
<!-- // } -->
<!-- // // 恢复图片边框 -->
<!-- // function hf(obj){ -->
<!-- // //获取图片 -->
<!-- // obj.className="sb"; -->
<!-- // } -->
</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>
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>`