我一辈子都搞不懂什么看起来这么简单。除此之外,我还有一个简单的css问题,我无法解决。-)
我试图通过改变类来改变背景图像的位置。
这不必在单个html文件中发生,因此
不涉及JavaScript。
这就像经典的“裁剪切换按钮”,其中
hover
状态将图像移动一组像素。然而,在这种情况下,它似乎不起作用。
在step1.html中,我的html如下所示:
<div id="progress" class="progress1">
<p>STEP 1/3 </p>
</div>
在step2.html中,我的html如下所示:
<div id="progress" class="progress2">
<p>STEP 2/3 </p>
</div>
注意唯一的变化是
class="progress1"
到
class="progress2"
.
我的css如下所示:
#progress{
position:relative;
display:block;
background: url(../images/progressBar.png) 65px 0px no-repeat !important;
width:565px;
height:36px;
line-height:36px;
margin:1em 0;
}
.progress1{
background: url(../images/progressBar.png) 65px 0px no-repeat !important;
}
.progress2{
background: url(../images/progressBar.png) 65px -36px no-repeat !important;
}
.progress3a{
background: url(../images/progressBar.png) 65px -72px no-repeat !important;
}
.progress3b{
background: url(../images/progressBar.png) 65px -108px no-repeat !important;
}
我也试过加上
background
在ID中声明,只更改类中的位置,如下所示:
background-position: 65px -108px
.