Remove line under image in link

前端 未结 8 990
北恋
北恋 2020-12-17 15:10

I have a few instances where I place image within a link. Normally if you set border=\"0\" there line under a link does not apply to the image. However, I had to specify DOC

8条回答
  •  被撕碎了的回忆
    2020-12-17 15:34

    If you want to have a special case for links with images, give the a element a class and remove the text-decoration for that class:

    HTML:

    
    

    CSS:

    a img
    {
      border: 0 none;
    }
    .image-link
    {
      text-decoration: none;
    }
    

    This is great if you only have an image within the link, however you have both text and images within the anchor.

    The solution for that would be to add a span around the text within the anchor:

     link text here
    

    and add an additional style in the stylesheet:

    .image-link span
    {
      text-decoration: underline;
    }
    

提交回复
热议问题