我一直在使用我的網站有一段時間的這個問題,所以我一直在使用圖片的標題,它的一切都很好,它改變了圖片,當我把它懸停在它上面,但後來完成把「家」,「新聞」,「登錄」,「註冊」和「聯繫」,我注意到,而不是將其全部旁邊的海誓山盟,這一切都可以疊加,就像這樣:CSS Header Image「Stacked」
的CSS代碼: #menubar { 寬度:50%; margin:0 auto 0 auto; }
.home {
display: block;
width: 240px;
height: 100px;
background: url('IMG/Heading_Normal_and_Hover.png');
background-position: 0 0;
}
.home:hover {
background-position: 0 100;
}
/***************************************************/
.news {
display: block;
width: 240px;
height: 100px;
background: url('IMG/Heading_Normal_and_Hover.png');
background-position: -240 top;
}
.news:hover {
background-position: -240 bottom;
}
/***************************************************/
.register {
display: block;
width: 240px;
height: 100px;
background: url('IMG/Heading_Normal_and_Hover.png');
background-position: 480 top ;
}
.register:hover {
background-position: 480 bottom;
}
/***************************************************/
.play { /*login*/
display: block;
width: 240px;
height: 100px;
background: url('IMG/Heading_Normal_and_Hover.png');
background-position: 720 top;
}
.play:hover {
background-position: 720 bottom;
}
/***************************************************/
.contact {
display: block;
width: 240px;
height: 100px;
background: url('IMG/Heading_Normal_and_Hover.png');
background-position: 240 top ;
}
.contact:hover {
background-position: 240 bottom;
}
/***************************************************/
您能夠重現這在[的jsfiddle(http://jsfiddle.net/)? – brandonscript
'.home,.news,.register,.play,.contact {float:left; }'並在'background-position'的數字旁邊加上'px'。 – mdesdev
@ r3mus我希望有一個簡單的解決方案(: – ToontownFred