用CSS設置背景圖像的大小?是否可以使用CSS設置背景圖像的大小?我想做這樣的事情:background: url('bg.gif') top repeat-y;background-size: 490px;但這樣做似乎是完全錯誤的.
3 回答

搖曳的薔薇
TA貢獻1793條經驗 獲得超6個贊
CSS 2
CSS 3 釋放力量
background-size
.
.stretch{/* Will stretch to specified width/height */ background-size: 200px 150px;}.stretch-content{/* Will stretch to width/height of element */ background-size: 100% 100%;}.resize-width{/* width: 150px, height: auto to retain aspect ratio */ background-size: 150px Auto;}.resize-height{/* height: 150px, width: auto to retain aspect ratio */ background-size: Auto 150px;}.resize-fill-and-clip{ /* Resize to fill and retain aspect ratio. Will cause clipping if aspect ratio of box is different from image. */ background-size: cover;}.resize-best-fit{/* Resize to best fit and retain aspect ratio. Will cause gap if aspect ratio of box is different from image. */ background-size: contain;}
cover
contain
圓
background-size: round
.resize-best-fit-in-repeat{/* Resize to best fit in a whole number of times in x-direction */ background-size: round auto; /* Height: auto is to keep aspect ratio */ background-repeat: repeat;}
附加說明

ITMISS
TA貢獻1871條經驗 獲得超8個贊
background-size: 200px 50px;
- 3 回答
- 0 關注
- 785 瀏覽