class="mystyle"
首先,不应该style="mystyle"
。
其次,由于<img
> 标记与具有mystyle
该类的元素相同,因此您的 CSS 是错误的。
您定义的 CSS 用于一个名为的元素,该元素mystyle
位于另一个名为img
.
您实际上想要定义样式的方式是img.mystyle
.
所以你的 CSS 代码看起来像这样:
img.mystyle {
border:0px;
}
你的 HTML 看起来像这样:
<img src="img" class="mystyle" />
不过老实说,我更愿意将此应用于所有图像,所以我根本不会费心mystyle
。只需有一个样式表条目img
即可自行删除任何边框。如果您以后需要向特定图像添加一个,您可以随时覆盖它,但我宁愿默认关闭它。
As for the mystery as to how the original code worked in Chrome/Safari but not Firefox/IE: I suspect that Chrome/Safari have dropped the default border. So it's not so much that they worked for you, it's more that those browsers don't even need you to do this, whereas Firefox and IE are still using the old default style for image links that defaults to giving them a border so they do need the override.