我有以下代碼,並希望實現類似下面的演示大綱。圖像顯示在div的頂部,當用戶垂直滾動時,其他圖像會重複顯示。兩個背景圖像一開始在另一端
但是,我想要顯示repeat.png究竟在哪裏stayontop.png垂直結束。我怎樣才能做到這一點?我嘗試了不同的background-position:center top, center bottom;
變化,但沒有運氣。
編輯:由於背景圖像高度在auto
模式(background-size:100% auto, 100% auto !important;
),其基於所述靜態高度基準如background-position:center 50px;
不幸工作在一個DIV寬度細的任何解決方案,但是,當用戶調整的div失敗。 (實際上當另一個用戶訪問該網站時,使用具有不同分辨率的移動電話。)是否有動態地設置它?
- + - + - + - + - + - + -
stayontop.png
- + - + - + - + - + - + -
repat.png
- + - + - + - + - + - + -
repat.png
- + - + - + - + - + - + -
repat.png
- + - + - + - + - + - + -
.....
.hede{
background: url("css/images/stayontop.png"), url("css/images/repeat.png");
background-repeat:no-repeat, repeat-y;
background-position:center top, center bottom;
background-attachment: scroll, scroll;
background-size:100% auto, 100% auto !important;
min-height:100%;
}
不能指定一個'頂'爲沿着y軸重複的背景值,因爲它會向上和向下重複。現在兩個答案都應該可以工作。 – powerbuoy 2012-07-30 22:00:51