css - 不确定如何从 css 中的图像中删除下划线

标签 css image underline

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

图片有下划线,文字也有。我希望图片不带下划线。

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>

没用。

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

最佳答案

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

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>

关于css - 不确定如何从 css 中的图像中删除下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37735412/

相关文章:

javascript - 悬停下划线的边距问题

javascript - 当我在 img 标签周围添加链接时,将元素居中对齐在 img 元素上不起作用

c++ - 如何使用 OpenGL 和 C++ 加载多个纹理?

HTML .png 图像作为按钮形状

flutter - 在 Flutter 中更改 TextField 的下划线

带有下划线 appcompat 的 Android 微调器

javascript - CSS - 列标题旋转以及滚动时固定标题

javascript - 使用 YepNope/Modernizr 加载外部 Google 字体样式表

html - 在悬停时使用 CSS 变换时闪烁的 div

css - 温泉用户界面 : align center