使用CSS的严格HTML中的图片边框 [英] Image border in Strict HTML using CSS

查看:156
本文介绍了使用CSS的严格HTML中的图片边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下在网站上显示可点击图片(无边框):

I have the following to display an clickable image (with no border) on a website:

<a href="link"><img src="img" border="0" /></a>

但是这不是严格的XHTML 1.0所以我也改变了:

However this is not strict XHTML 1.0 so I changed it too:

<img src="img" class="mystyle" />

和CSS:

mystyle img
{
    border: 0px;
}

但是这只能在Safari& Chrome并不适用于IE& FireFox。

However this only works in Safari & Chrome and does not work in IE & FireFox.

我知道w3验证器不是必要的,但是想知道是否有人遇到这个问题,可能还有一个修复:)

I understand that the w3 validators aren't necessary but was wondering if anyone has come across this and possibly a fix :)

编辑:样式是一个拼写错误,我的意思是类;)

Style was a typo, I meant class ;)

谢谢

推荐答案

需要一些更改( 我惊讶地发现它在任何浏览器中工作,看起来像是基于webkit的浏览器请勿在图片链接周围放置边框,如@Adriano在其评论中提及的

Needs some changes (i am surprised to hear that it works in any browser, well looks like webkit-based browsers do not put a border around image links, as @Adriano mentioned in his comment)

b
$ b

in Html

<img src="img" class="mystyle" />

,因为 style 值直接,而不是引用css规则。 class 属性用于

because the style attribute is to assign property values directely, and not to reference a css rules. The class attribute is used for that.

CSS

and in CSS

.mystyle
{
    border: 0px;
}

因为表示类规则你放一个 代表ids )。我们从那里移除了 img ,因为这意味着你想要风格 img 具有 mystyle 类的元素。

because to signify a class rule you put a . to it (# for ids). And we removed the img from there because it would mean that you want to style img tags that are contained in some other element that has the mystyle class.

这篇关于使用CSS的严格HTML中的图片边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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