2015-09-05 84 views
0

我嘗試在我的網站背景的CSS定位圖像。我希望這些圖像在我的背景上始終保持相同的位置。但我的背景圖片變化的大小和圖像移動...位置圖像(背景大小的變化)

背景:

html{ 
background: url("../images/example.gif") no-repeat bottom right fixed; 
-webkit-background-size: cover; 
-moz-background-size: cover; 
-o-background-size: cover; 
background-size: cover; 
} 

圖像:

.image{ 
position: fixed; 
right: 219.5px; 
top: 368px; 
} 

任何想法如何,我可以保持圖像總是相同的位置?

+0

請分享任何工作演示/ jsfiddle或活動鏈接,我們可以檢查此問題,以便我們可以以更好的方式提供幫助... thanx –

回答

0

請嘗試了這一點。則CSS可以解決你的問題:)

body { 
      background: url('../images/bg.jpg') no-repeat center center fixed; 
      -webkit-background-size: cover; 
      -moz-background-size: cover; 
      -o-background-size: cover; 
      background-size: cover; 
      color:#fff; 
      background-color:#FFF; 
      position: relative; 
} 

如果以上一次不行試試下面

body 
     { 
     background-image: url("../images/background.png"); 
     background-repeat: no-repeat; 
     background-size: cover; 
     background-attachment: fixed; 
     } 
+0

不要工作:-( – AsdMan

+0

ya等待先生@AsdMan –

+0

測試您的答案,發佈之前 –

0

代碼,請試試這個:

html{ 
background: url("../images/bg.jpg") no-repeat center center fixed; 
     -webkit-background-size: cover; 
     -moz-background-size: cover; 
     -o-background-size: cover; 
     background-size: cover; 
     color:#fff; 
     background-color:#FFF; 
     position: relative; 
} 

CSS:

.image{ 
position: fixed; 
right: 219.5px; 
top: 368px; 
} 

DEMO PAGE

+0

不要工作:-( – AsdMan

+0

請參閱演示頁面@AsdMan –