仅当锚标记包含img时,才从图像中删除链接下划线 [英] remove link underline from image only if the anchor tag contains an img
问题描述
<a href="#">
<img width="103" height="100" src="img source">
</a>
上面的html代码我使用下面的css
for the above html code I am using the following css
a {
border-bottom-style: dotted;
border-bottom-width: 1px;
}
a img {
border: 0 none;
}
基本上我想实现这里来强调文本链接,同时保持img链接没有任何下划线。但我想通过样式的文本链接我也是样式图像链接,我想要链接中的任何图像不应该加下划线。
Basically what I am trying to achieve here to underline the text links while keeping img links without any underline. however I guess by styling the text links I am also styling image links, I want any image in a link should not be underlined.
任何人都可以建议这方面的工作?
Can any one suggest work around for this?
推荐答案
下划线是由a上的文本修饰造成的。因此,只需将 text-decoration:none
应用到a。
The underline is caused by the text decoration on the a. So just apply text-decoration:none
to the a.
编辑:there目前没有CSS方式可以将一个样式应用于以 img
为子元素的任何 a
。 CSS没有选择器。所以你必须给这些一个
是唯一的给他们类(或其他属性)并应用CSS到这些类,或者运行一些脚本测试
s
,并且
a
风格。
Edit: there is currently no CSS-only way to apply a style to "any a
that has an img
as its child". CSS does not have selectors for that. So you'll either have to make these a
s unique by giving them classes (or other attributes) and apply the CSS to those classes, or run some script that tests for img
s in a
s and gives those a
s the desired style.
这篇关于仅当锚标记包含img时,才从图像中删除链接下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!