chrome/safari display border around image

后端 未结 11 901
暖寄归人
暖寄归人 2020-12-03 10:30

Chrome and Safari are displaying a border around the image, but I don\'t want one. There is no border in Mozilla. I\'ve looked through the CSS and HTML, and I can\'t find an

11条回答
  •  -上瘾入骨i
    2020-12-03 11:00

    To summarise the answers given already: your options to remove the grey border from an img:not([src]), but still display an image using background-image in Chrome/Safari are:

    • Use a different tag that doesn't have this behaviour. (Thanks @Druvision)
      Eg: div or span.
      Sad face: it's not quite as semantic.

    • Use padding to define the dimensions. (Thanks @Gonzalo)
      Eg padding: 16px 10px 1px; replaces width:20px; height:17px;
      Sad face: dimensions and intentions aren't as obvious in the CSS, especially if it's not an even square like @Gonalo's example.

提交回复
热议问题