解决方法
你可以做到这一点,而不需要额外的元素或伪元素:
http://cssdeck.com/labs/t6nd0h9p
img { outline: 1px solid white; outline-offset: -4px; }
IE9& 10不支持outline-offset属性,否则支持是好的:http://caniuse.com/#search=outline
不需要知道图像尺寸的替代解决方案:
http://cssdeck.com/labs/aajakwnl
<div class="ie-container"><img src="http://placekitten.com/200/200" /></div> div.ie-container { display: inline-block; position: relative; } div.ie-container:before { display: block; content: ''; position: absolute; top: 4px; right: 4px; bottom: 4px; left: 4px; border: 1px solid white; } img { vertical-align: middle; /* optional */ }