【发布时间】:2013-12-25 16:24:13
【问题描述】:
以下是我的小提琴,我试图将背景图像(位置居中)放到宽度设置为 100% 的 div 中,如果图像的背景宽度为 20px 并且用户屏幕为 100px,那么我想要图像不会拉伸宽度,模糊渐变部分会填充图像左右部分的区域。请告诉我该怎么做?
#background {
/* fallback */
background-color: #2F2727;
background-image: url(http://farm5.staticflickr.com/4004/4335972718_a491a3076d.jpgimages/radial_bg.png);
background-position: center center;
background-repeat: no-repeat;
width:100%;
height:250px;
/* Safari 4-5, Chrome 1-9 */
/* Can't specify a percentage size? Laaaaaame. */
background: -webkit-gradient(radial, center center, 0, center center, 460, from(#1a82f7), to(#2F2727));
/* Safari 5.1+, Chrome 10+ */
background: -webkit-radial-gradient(circle, #1a82f7, #2F2727);
/* Firefox 3.6+ */
background: -moz-radial-gradient(circle, #1a82f7, #2F2727);
/* IE 10 */
background: -ms-radial-gradient(circle, #1a82f7, #2F2727);
/* Opera couldn't do radial gradients, then at some point they started supporting the -webkit- syntax, how it kinda does but it's kinda broken (doesn't do sizing) */
}
【问题讨论】:
-
你的头像坏了
-
@Kirk 使用你喜欢的任何 xyz 图像我只是想知道如何在图像周围填充。
-
据我所知。无论宽度如何,您都希望图像居中?