2015-11-01 96 views
1

在我的MVC應用程序中,每頁都有一個包含圖像的頁腳。如果可能,我想將圖片居中。我當前的CSS看起來如下:CSS - 居中頁腳背景圖片

footer { 
    position:absolute; 
    bottom:-150px; /* This puts the footer 100px below the bottom of the page*/ 
    width:70%; 
    height:175px; /* Height of the footer */ 
    background-image: url("/Images/Footer/Footer3.png"); 
    background-repeat: no-repeat; 
    border-top: 1px solid darkgray; 
} 

我需要添加什麼來居中映像?

回答

4

您需要添加background-position屬性,如:

又見here

footer { 
    position:absolute; 
    bottom:-150px; /* This puts the footer 100px below the bottom of the page*/ 
    width:70%; 
    height:175px; /* Height of the footer */ 
    background-position: center; 
    background-image: url("/Images/Footer/Footer3.png"); 
    background-repeat: no-repeat; 
    border-top: 1px solid darkgray; 
}