IMG标签上有奇怪的边框 [英] Strange border on IMG tag

查看:449
本文介绍了IMG标签上有奇怪的边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML:

<html>
<body>

<header>
    <img class="logo" />
</header>

</body>
</html>

CSS:

* {
    margin:0px;
    padding:0px;
    border:none;
}

img.logo {
    width:126px;
    height:50px;
    background-image:url('images/logo.png');
}

每次我尝试风格的IMG这样一个奇怪的边框出现。即使我会放置border:0px;或border:none;

One way or another everytime i try to style an IMG like this a strange border appears. Even if I would place border:0px; or border:none; in the img.logo css the border remains.

推荐答案

这是使用<$时出现的默认特殊边框c $ c> img 元素,其中a src 属性设置为不存在的东西(或没有 src )。

It's the default "special" border that appears when you use an img element with an a src attribute set to something that doesn't exist (or no src at all).

一个常见的解决方法是将 src 设置为 blank.gif 档案

A common workaround is to set the src to a blank.gif file:

<img class="logo" src="blank.gif" />



我必须指出,在这种情况下,使用< img> background-image 。只需设置 src 属性并忽略 background-image

I have to point out that it (in this case) makes no sense to use an <img> with background-image. Just set the src attribute and forget about background-image.

这篇关于IMG标签上有奇怪的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆