使用bootstrap时,Sprite图像显示带边框

时间:2014-10-24 23:35:54

标签: css twitter-bootstrap-3 css-sprites

我有这样的精灵:

enter image description here

并使用以下css显示:

.sprite { background: url('sprite.png') no-repeat top left; width: 40px; height: 40px;  } 
.sprite.Live { background-position: 0px 0px;  } 
.sprite.Private { background-position: -50px 0px;  } 
.sprite.Public { background-position: -100px 0px;  }  

但图像周围总是有边框。我确保设置了img {border:0}。我正在使用Bootstrap 3.这是由bootstrap引起的吗?

enter image description here

1 个答案:

答案 0 :(得分:1)

事实证明它的Chrome问题。这是我能找到的最接近的答案。

It's because you are using an img tag with no src attribute. Chrome is essentially indicating the size of the container with nothing in it.

https://stackoverflow.com/a/9173082/772481