简体   繁体   English

当某些链接悬停在链接上时,如何删除下划线?

[英]How to remove underlining when a link is hovered over for certain links?

HTML HTML

<div class = "shared_link_post_container">
    <a id="{{post.status_id}}_shared_link_img" href="{{post.link}}" target="_blank">
        <img src="{{post.picture}}">
    </a>
    <a id="{{post.status_id}}_shared_link_text" class="shared_link_text" href="{{post.link}}" target="_blank">
        <div id="{{post.status_id}}_clickable_text_box" class="clickable_text_box">
            <br>
            <span class="shared_link_name">{{post.name}}</span>
            <br>
            <span class="unlinked shared_link_caption">{{post.caption}}</span>
            <br>
            <br>
            <span class="unlinked shared_link_description">{{post.description}}</span>
        </div>
    </a>
</div>

I want the links with the class unlinked to not have the underline when a link is hovered over. 我希望在链接悬停时, unlinked链接类的链接不带有下划线。 I tried: 我试过了:

CSS CSS

.unlinked {
    color: gray;
    font-weight: normal;
    text-decoration: none;
}

This doesn't seem to work, mainly because my unlinked class should be a class. 这似乎并不工作,主要是因为我的unlinked类应该是a类。 However, I don't want to remove the underlining for all my links, just the unlinked class. 但是,我不想删除所有链接的下划线,只是要删除unlinked链接的类。

Turn your span s into block level elements and then to this: span变成块级元素,然后执行以下操作:

.shared_link_name {
  display: inline-block;
  text-decoration: underline;
}
.shared_link_name:hover {
  text-decoration: none;
}

CodePen here CodePen在这里

Use the below code: 使用以下代码:

DEMO JSFIDDLE 演示JSFIDDLE

.unlinked {
     display: inline-block;
     color: gray;
     font-weight: normal;
     text-decoration: underline;
}

/* For hover condition */
.unlinked:hover {
     text-decoration: none;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 悬停在上方时如何使链接文本更改颜色而不是下划线 - How to make the link text change color instead of underlining when hovered over 如何将链接放置在细分上,以使它们的下划线(当悬停时)位于整个父div下方的边距线上? - How to position links on a subdiv so that their underlining (when hovered over) sits on top of a margin line ruled under the entire parent div? 当框悬停时出现文本,但是如何从文本链接中删除下划线? - Text appears when box is hovered over, but how to remove underline from text link? 当LINK悬停在链接上时,如何使插入符号改变颜色? - How to make a caret in a link change color when the LINK is hovered over? 将鼠标悬停在 CSS 上时,如何仅在链接上添加下划线 - How to only have an underline on a link when hovered over CSS 如何检测某个标签是否被悬停 - How to detect if a certain tag is being hovered over 如何更改链接的颜色,删除其下划线并调整其大小? - How can I change the color of the link, remove its underlining and resize it? 如何删除我的 HTML email 中的链接下划线? - How do I remove link underlining in my HTML email? 链接悬停时链接不会改变颜色 - Links aren't changing color when hovered over HTML和CSS的新功能,将鼠标悬停在链接上时链接会移动 - New to HTML and CSS, links are moving when hovered over
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM