How to remove link below image (but keep on text)?

青春壹個敷衍的年華 提交于 2019-12-23 05:11:05

问题


I had a link with text and an image. I don't want the image to have an underline under it but I do want the text to have an underline. Is there anyway to support this without breaking these down into two seperate links? Here is an example picture:


回答1:


No, there is no way to achieve that without splitting the link into two parts.

The alternative is to put border-bottom: 1px solid #000 on to the element containing the text, however this will not behave in the same was as a native A element, with hover, active and visited states - at least not without the intervention of javascript.




回答2:


You could easily do something structured like:

<a><span>text</span><img /></a>

You could then remove the underline from a and apply underlining to a span.

Demo here: http://jsfiddle.net/chrisvenus/pdrz9/

I should note that the following will not work:

img {
  text-decoration: none;
}


来源:https://stackoverflow.com/questions/8036754/how-to-remove-link-below-image-but-keep-on-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!