2012-08-06 26 views
0

首先,我對此非常感興趣,請耐心等待。確保div是100%寬度,不會損壞菜單

我實現了一個很酷的「上滾動腳本褪色」來my site.

然而,正是我希望做的是有像在像fastcocreate's網站上分支寬度爲100%。

這是我的工作在div:

<div class="home" style="background-image: url(http://payload51.cargocollective.com/1/7/237315/3336908/HomeImage_o.jpg); background-attachment: fixed; height: 560px; width: 100%; opacity: 1; background-position-y: 0px; background-position-x: center; background-repeat: no-repeat no-repeat; background-size: 100% 560px;"> 
</div> 

現在,我已經嘗試添加一個「背景尺寸:100%的汽車;」到div,這是訣竅,除了這是我的文本奇怪的事情。例如,如果我讓瀏覽器更細,文本就不會隨之移動 - 所以我放棄了這個想法。

接下來我將它更改爲'background-size:100%560px;'解決了這個問題。但是另一個原因是,當你縮小瀏覽器的時候,圖像會變小,或者當我把它變得更寬時,圖像就會伸展。

我覺得我更接近上面的一個,但我正在尋找解決拉伸圖像問題。我是否需要上傳比當前尺寸更大的圖片?

正如我前面所說的these guys做得很好。

回答

0

它會出現fastocreate具有最小寬度設置爲自己的形象,你有沒有嘗試過

min-width: 100%; 
height: auto; 

Im相當肯定多數民衆贊成fastocreate確實

最好, -b

*另外,儘量使你的瀏覽器中的 「檢查元素」。它在試圖反映某人的風格時非常有用。

編輯:

響應您的評論,你可以嘗試做一個jQuery的功能,將調整其大小。

例如

function resize(){ 
    var height = $('img').width/2; //sets variable height to the width divided by 2 
    $('img').height(height); // sets the value of the height to the variable height 
}; 

或類似的東西。

+0

當我添加到div,圖像消失。 – Michael 2012-08-06 15:52:36