混淆css背景图片拉伸

时间:2014-09-15 08:03:34

标签: css background background-image

我的图片宽度为50px,高度为20px,然后我将其设置为div的背景:

background: url('close.png') no-repeat 0 0;
width: 71.875px;
height: 28.75px;
position: absolute;
top: 50px;
background-position:center;
background-size:100%,100%;

虽然div的宽度和高度与图像不同,但比例相同,都是5: 2。但结果很奇怪:

enter image description here

enter image description here

div与其元素之间存在间隙线。看起来图像不会在顶部伸展。

为什么会这样?我该如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

您无法在css规则中使用逗号

background-size:100%,100%;应为background-size:100%;

答案 1 :(得分:0)

你应该,

background-size:100%;