2016-10-31 25 views
-2

的大小不同,我已經把一個像我的網站上,背景圖片,但我不知道爲什麼,這是不同的,以人到另一個人,(由顯示器的尺寸)CSS形象定位顯示了顯示器

例如:在我的電腦,它顯示了這種方式:

在另一臺PC,不同尺寸的顯示器,它會顯示不同。

這是爲什麼?我試圖添加50%50%不重複,但它沒有工作

我真的不知道該怎麼做。

CSS:

body {font-family:Arial, Sans-Serif; background-image: url("http://vestigedayz.com/Resurse/images/header-background.jpg"); 
    background-repeat: no-repeat; 
    background-attachment: fixed; 
    background-position: center; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
} 

HTML

<body> 
.... 
</body> 

body {font-family:Arial, Sans-Serif; background-image: url("http://vestigedayz.com/Resurse/images/header-background.jpg"); 
 

 

 

 

 

 
    background-repeat: no-repeat; 
 
    background-attachment: fixed; 
 
    background-position: center; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    background-size: cover; 
 
}
<body> 
 
    </body>

+0

我已經添加了代碼。 在此之前,我有問題的CSS代碼。 –

+0

因爲您正在使用封面,具體取決於顯示器的分辨率,取決於圖像的外觀。例如 - 在這個小提琴中,假裝三個div是不同的顯示器分辨率,圖像看起來各不相同:https://jsfiddle.net/yd39v79p/1/ – Pete

+0

我該怎麼辦才能解決這個問題?用

回答

0

一種解決方案是使用圖像標籤帶班,然後應用下面的CSS但它可能成爲如果圖像的尺寸比例不符合,則會失真監視器的那個。

<img src="your/image/path.jpg class="your-image-class" /> 

然後CSS:剪斷

body,html { 
    height: 100%; 
    width: 100%; 
} 

.your-image-class { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
}