[問題] 用了background-repeat但是背景沒重複

看板Web_Design作者 (休息)時間19年前 (2006/08/08 17:25), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
各位大大好, 我現在修改網頁的CSS背景遇到background-repeat沒反應的問題。 目的: 我希望把中間的div的背景設為centerbackground.jpg(7px高的白底綠框), 然後希望這個背景重複填滿整個中間的div,一直到最下面的footer,如下: http://blog60.fc2.com/x/xiongmaolai/file/desiredbackground.jpg
問題: (1)當我用background-repeat: repeat-y,背景沒有重複,且還不見掉, 只看得到最底的綠色背景,如下: http://blog60.fc2.com/x/xiongmaolai/file/backgroundrepeat.jpg
(2)當我不用background-repeat,假設改用定義height:400px, 背景的白底綠框會一直延伸到400px。 樣式:http://blog60.fc2.com/x/xiongmaolai/file/defineheight.jpg
可是由於我無法確定整個高度為多少(依文章長度),所以不是解決的方法。 請問我的background-repeat到底哪裡設錯了? 為什麼背景會不見掉? 請大家幫忙解惑,謝謝。 ============================================================================= (1)background-repeat #outer { position: relative; margin: 0 auto; padding: 0px; width: 780px; background: url(http://blog60.fc2.com/x/xiongmaolai/file/centerbackground.jpg); background-repeat: repeat-y; } (2)定義height #outer { position: relative; margin: 0 auto; padding: 0px; width: 780px; height: 400px; background: url(http://blog60.fc2.com/x/xiongmaolai/file/centerbackground.jpg); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.189.178.212 ※ 編輯: xiongmao 來自: 59.189.178.212 (08/08 18:31)

08/08 22:45, , 1F
那跟background-repeat沒關係 是因你內容區塊都用絕對定位
08/08 22:45, 1F

08/08 23:01, , 2F
所以你#outer高度永遠是0
08/08 23:01, 2F

08/09 13:08, , 3F
真的耶!問題解決了,非常謝謝你。
08/09 13:08, 3F
文章代碼(AID): #14s5YU7f (Web_Design)
文章代碼(AID): #14s5YU7f (Web_Design)