【问题标题】:not sure how to remove underline from image in css不知道如何从css中的图像中删除下划线
【发布时间】:2016-06-09 20:18:44
【问题描述】:

我正在制作的网站在超链接中的某些文本旁边有一张图片。

图像带有下划线,文本也带有下划线。我希望图像不带下划线。

a {
   -moz-transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
   -webkit-transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
   -ms-transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
   transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
   border-bottom: dotted 1px;
   color: #0066cc;
   text-decoration: none;
 }
 a:hover {
   border-bottom-color: transparent !important;
   color: #0066cc !important;
   text-decoration: none;
 }
 img {
   outline: none !important;
   text-decoration: none !important;
   border-bottom-color: transparent !important;
   border-bottom: none;
   outline-width: 0px;
 }
<a href="domain.com"><img src="pic.gif">check this out></a>

没有用。

如果您将鼠标悬停在图像上,下划线会消失,但我希望它永远不会出现。

【问题讨论】:

  • 那你为什么写border-bottom: dotted 1px;
  • 我希望它在你没有悬停在它上面时加下划线。

标签: css image underline


【解决方案1】:

如果您只想删除图片下方的线条,请使用以下代码:-

CSS :-

a 
{
    -moz-transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
    -webkit-transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
    -ms-transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;

    color: #0066cc;
    text-decoration: none;
}
a span{
border-bottom: dotted 1px;
}
a span:hover {
    border-bottom-color: transparent !important;
    color: #0066cc !important;
    text-decoration: none;
}

HTML :-

<a href="domain.com"><img src="pic.gif"><span>check this out></span></a>

如果要从整个图像和文本中删除行,请使用以下代码:-

CSS :-

a 
    {
        -moz-transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
        -webkit-transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;
        -ms-transition: color 0.2s ease-in-out, border-bottom-color 0.2s ease-in-out;

        color: #0066cc;
        text-decoration: none;
    }
a span{
border-bottom: dotted 0px;
}
a span:hover {
    border-bottom-color: transparent !important;
    color: #0066cc !important;
    text-decoration: none;
}

HTML :-

<a href="domain.com"><img src="pic.gif"><span>check this out></span></a>

【讨论】:

  • 这也始终隐藏文本的下划线。
【解决方案2】:

将文本放入&lt;span&gt;&lt;/span&gt;,从链接中删除下划线并仅为该范围设置下划线。它应该可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-16
    • 1970-01-01
    • 2022-01-15
    • 2012-02-07
    • 1970-01-01
    • 2012-05-27
    • 2019-11-25
    相关资源
    最近更新 更多