2014-06-30 48 views
0

例[1] http://themeforest.net/item/skilt-a-wordpress-theme-for-frequent-bloggers/7936499?ref=tbd如何讓我的形象去的其他層後面

我怎麼怎麼有那麼一個背景圖像的背景色爲文本(額外圖像的影響,並能我得到的文字背景沿着頂部流動)?我知道我在問一個模糊的問題,但我仍然是一個結局。^_^ 謝謝(事先如果你能回答它)。

+1

z-index ........ –

+1

thx's(/◕ヮ◕)/ ..................... – Nub

回答

0

該網站有一個具有固定位置並覆蓋整個瀏覽器窗口的背景圖片。

body { 
    background-color: #0c0c0c; 
} 

#background-image { 

    opacity: 0.7; 
    background-image: url(some_image.jpg); 

    position: fixed; 
    top: 0; 
    right: 0; 
    bottom: 0; 
    left: 0; 
    z-index: 2; 
    background-position: center; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    -webkit-background-size: cover; 
    background-size: cover; 
    width: 100%; 
    height: 100%; 
} 

隨着HTML這樣的:

<div id="background-image"></div> 
<div class="container> 
    <div id="content"> 
     <p>Lorem ipsum some stuff</p> 
    </div> 
</div> 

它是一種非常酷的效果,你應該嘗試複製它一個網站,你就。繼續努力,直到找出答案。

這是一個良好的開端:既http://css-tricks.com/perfect-full-page-background-image/

+0

謝謝...解釋很多:) – Nub

0

你總是可以設置背景圖片,並在同一時間與CSS背景色:

body { 
    background-image:url(url/to/your/image); 
    background-color:#CCCCCC; 
} 

編輯:如果你問如何保持背景圖像的位置,您還可以添加background-attachment:fixed;。這比製作具有固定位置的單獨div更簡單,而且它在語義上也是正確的。

相關問題