![](/img/trans.png)
[英]Centred, absolutely positioned element looking good in all but Firefox7 for windows
[英]Background image not centred in Firefox7 for Windows
使用Browserlab,在以下站點上,背景圖像似乎不在Firefox7 for Windows中居中: http ://carolineelisa.com/wp/boy/
我正在使用的CSS如下,如屏幕截圖所示。
有什么想法我可以解決這個問題嗎?
謝謝!
CSS:
html {
background: url(images/background.jpg) no-repeat top center #0f0c0b;
}
該位置的第一個值是水平值,第二個是垂直值。 所以交換top
和center
:
background: url(images/background.jpg) no-repeat center top #0f0c0b;
標准參考: http : //www.w3.org/TR/css3-background/#ltbg-positiongt
即使瀏覽器的尺寸< 980px
,您的html頁面背景也會保持居中< 980px
,但是一旦尺寸變小,容器就會將其自身對齊到視口的左側。
現在,要解決您的問題,如果寬度小於980像素,則應將html的背景與左側和頂部對齊。 因此,使用一些響應式CSS:
@media screen and (max-width: 980px) {
html{
background-position: left top;
}
}
嘗試這個?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.