用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 关注
- 756 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消