素材:
效果:默认显示上半部分,鼠标移到按钮上触发hover显示下半部分。
代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>购物车动态变化按钮</title>
<style type="text/css">
a:link{
/*1.将行内元素转成行内块元素*/
display: inline-block;
/*2.对行内块元素定义大小*/
width:67px;
height:31px;
/*3.导入图片背景*/
background:url("images/110.png");
}
a:visited{
}
a:hover{
background:url("images/110.png") bottom;
}
a:action{
}
</style>
</head>
<body>
<a href="#"></a>
</body>
</html>
总结:
1.要对行内元素(如p、a、input、span等标签)进行大小的设定,需要:
①.将行内元素转成行内块元素
②.对行内块元素定义大小
……
2.background的连写:
①.background-color:背景色
②.background-image:背景图片
③.background-repeat:repeat(默认)|no-repeat|repeat-x|repeat-y 背景平铺
④.background-position:left|right|center|top|bottom 背景定位
⑤.background-attachment:scroll | fixed 背景是否滚动
综合连写即:background:red url("1.png") no-repeat 30px 40px scroll;
注意:连写的时候没有顺序要求,url为必写项。