CSS - 嵌套 anchor 标记链接

标签 css

我想在 <a> 中创建嵌套链接标签

例子:

<a href="#">This is a link <a id="sup">sup text</a> end of the link</a>

CSS:

a#sup{
    color:#19578e;
    font-family: Verdana;
    font-size: 8pt;
    vertical-align: top;
}

a {
    font-family: Arial;
    color: #19578e;
    font-size: 10pt;
    font-weight: normal;
    font-style: normal;
    text-decoration: none;
}

但是,像这样只有“This is a link”指向链接...

最佳答案

使用 SPAN,因为您不能嵌套 anchor 标记。

<a href="#">This is a link <span id="sup">sup text</span> end of the link</a>

Ok I'll use span, but how to make the span having the same propreties than anchor tag when anchor tag is hover ?

将悬停状态添加到“sup”元素的 CSS。

a, a:hover #sup {
    font-family: Arial;
    color: #19578e;
    font-size: 10pt;
    font-weight: normal;
    font-style: normal;
    text-decoration: none;
}

如果你有更多的地方,你可以简单地使用:

a, a:hover span { ... }

关于CSS - 嵌套 anchor 标记链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20552611/

相关文章:

javascript - 伪元素 (::before) 上的 CSS3 过渡不起作用

javascript - Dojo/Dijit TitlePane( basemap 库)放置

html - 列之间有边框的 Bootstrap 网格

css - 图片作为背景

css - 使用 Font Awesome 图标代码而不导入它

html - 在 angularjs 中使用指令时在列中定位 Div

jQuery - 如何保持元素相对于屏幕的垂直位置?

css - macbook pro 15"的媒体查询

javascript - 使用 jQuery 在 HTML 页面之间转换?

html - 1 个 DIV 上的多种背景颜色