- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试添加带有伪元素:after
的下划线来注释一些文本。
我的问题是,我想强调下划线。在此示例中,这是短语“实际上确实可以...”和“ ...不起作用”。
.test {
margin-top: 60px;
}
span.annotation {
position: relative !important;
display: inline-block !important;
}
span.annotation:hover {
cursor: pointer;
box-shadow: none;
}
span.annotation:after {
content: '';
position: absolute;
left: -.15em;
width: calc(100% + .5em);
transition: all .2s;
height: 3px;
}
span.annotation.firstLevel:after {
z-index: -3;
bottom: -0.5em;
}
span.annotation.secondLevel:after {
z-index: -2;
bottom: -0.2em;
}
span.annotation.thirdLevel:after {
z-index: -1;
bottom: 0.1em;
}
span.annotation:hover:after {
width: calc(100% + 1em);
content: attr(title);
text-align: center;
font-size: 8px;
color: #444;
}
span.annotation.firstLevel:hover:after {
height: calc(100% + 2.3em) !important;
}
span.annotation.secondLevel:hover:after {
height: calc(100% + 1.9em) !important;
}
span.annotation.thirdLevel:hover:after {
height: calc(100% + 1.6em) !important;
}
span.additionalType:after {
background: gold;
}
span.annotation.testA:after {
background: gainsboro;
}
span.annotation.testB:after {
background: deepskyblue;
}
span.annotation.testX:after {
background: gold;
}
span.annotation.testC:after {
background: deeppink;
}
span.annotation.testD:after {
background: tomato;
}
span.annotation.testE:after {
background: greenyellow;
}
<div class="test">
This is <span title="TestA" class="annotation testA firstLevel"><span title="TestB" class="annotation testB secondLevel"><span title="TestC" class="annotation testC thirdLevel">pretty good example</span> for the</span> <span title="TestD" class="annotation testD secondLevel">Text Annotation</span> but <span title="TestX" class="annotation testX thirdLevel">actually <span title="TestE" class="annotation secondLevel testE">it</span> do not work</span></span>
</div>
最佳答案
这似乎是一个堆栈上下文问题。将z-index:0
添加到注释元素以隔离每个元素的上下文,并避免让所有:after
属于同一堆叠上下文。
.test {
margin-top: 60px;
}
span.annotation {
position: relative !important;
display: inline-block !important;
z-index:0;
}
span.annotation:hover {
cursor: pointer;
box-shadow: none;
}
span.annotation:after {
content: '';
position: absolute;
left: -.15em;
width: calc(100% + .5em);
transition: all .2s;
height: 3px;
}
span.annotation.firstLevel:after {
z-index: -3;
bottom: -0.5em;
}
span.annotation.secondLevel:after {
z-index: -2;
bottom: -0.2em;
}
span.annotation.thirdLevel:after {
z-index: -1;
bottom: 0.1em;
}
span.annotation:hover:after {
width: calc(100% + 1em);
content: attr(title);
text-align: center;
font-size: 8px;
color: #444;
}
span.annotation.firstLevel:hover:after {
height: calc(100% + 2.3em) !important;
}
span.annotation.secondLevel:hover:after {
height: calc(100% + 1.9em) !important;
}
span.annotation.thirdLevel:hover:after {
height: calc(100% + 1.6em) !important;
}
span.additionalType:after {
background: gold;
}
span.annotation.testA:after {
background: gainsboro;
}
span.annotation.testB:after {
background: deepskyblue;
}
span.annotation.testX:after {
background: gold;
}
span.annotation.testC:after {
background: deeppink;
}
span.annotation.testD:after {
background: tomato;
}
span.annotation.testE:after {
background: greenyellow;
}
<div class="test">
This is <span title="TestA" class="annotation testA firstLevel"><span title="TestB" class="annotation testB secondLevel"><span title="TestC" class="annotation testC thirdLevel">pretty good example</span> for the</span> <span title="TestD" class="annotation testD secondLevel">Text Annotation</span> but <span title="TestX" class="annotation testX thirdLevel">actually <span title="TestE" class="annotation secondLevel testE">it</span> do not work</span>
</span>
</div>
关于html - 嵌入跨度和伪元素的问题:之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54582611/
如标题所示,我正在寻找有关伪/冒号 header 字段用途的一些信息,即我想知道为什么我们有第二种类型的 header 字段... 另外 - 我知道在 http2 中使用伪/冒号 header 字段代
(伪)多线程:借助外力 利用WEB服务器本身的多线程来处理,从WEB服务器多次调用我们需要实现多线程的程序。 QUOTE: 我们知道PHP本身是不支持多线程的, 但是我们的WEB服务器是支持多线程的
您如何在 HDL (verilog) 中实现硬件随机数生成器? 需要考虑哪些选项? 这个问题是在self-answer之后格式。鼓励添加答案和更新。 最佳答案 正如摩根的回答中所指出的,这只会产生一个
我写了这个CSS: div { width: 500px; height:150px; margin-left:150px; background: lightblue; } div:
这是我要解决的问题:从数据库A读取一个字符串,将该字符串转换为Date对象,将Date对象存储到数据库B中。 例)数据库A:从数据库A读入日期字符串“ 2015-03-08 02:00:00”,转换为
我想创建 std::fscanf() 的 sibling (我知道这是一个 C 函数)。所以,我的界面是这样的: template std::size_t ts_scanf(is, format,
运行 PostgreSQL 7.x(是的,我正在升级) 问题: 如果没有返回数据,我有三到四个字段需要设置。 正在考虑这样的事情 SELECT CASE WHEN default_fie
出于某种原因,我很难在 JS 中为我的游戏执行以下代码: 假设我们要求用户在棋盘上移动一个棋子。他们可以做的位置是位置A、位置B或位置C。每个位置一次只能容纳一件。否则为无效移动。 第一个用户决定
我已经毫无问题地编写了霍夫曼树的代码,但现在我希望在文件和树中添加伪 EOF,以便我知道何时停止从文件中读取。 我完全掌握了伪 EOF 的概念。我还了解到没有 ASCII 值 > 255 的字符。 我
给定一个按钮 ::after 当被触发时,伪 :after 类需要有一个类 search-active 切换,为按钮设置背景颜色 .primary .search:after, .primary
我想让第一行的文本像第二行一样缩进 (50px)。有什么办法吗?非常感谢! body{ counter-reset: h2counter; } h1{ counter-reset: h2counter
:before 或 :after 这样的伪元素是否可以从父元素的不同属性继承值? 在我的例子中,我有一个第三方组件设置其元素运行时的背景颜色...我需要继承该颜色并将其设置为伪元素的边框颜色。 最佳答
在并行循环中请求随机数总是返回相同的伪随机数。我怎样才能避免这种情况? % workers initialization: if matlabpool('size') == 0 matlabp
假设最大IP可以包含每个“点”括号中的最大数量999,即999.999.999.999 是最大的可用值。 我已经在计算器中检查了正则表达式 ([0-9]+.){3}[0-9]。那么,为什么程序抛出运行
我对随机数生成的概念非常陌生,我需要为用c编写的工作创建自己的算法(内置的随机数生成器对我不起作用)。 有人能给我介绍一个很好的主题,这样我就可以理解这个概念了吗?到目前为止,我所发现的一切似乎都是用
假设我有一个数字序列:{n, n+1, n+2, ... n+m} 在不提前存储数字的情况下,我想创建一个函数 f(),给定序列 {1,2,3,...m} 将以随机(或至少伪)的方式吐出原始集合随机)
什么是伪 tcp channel ,如何实现? 最佳答案 伪 TCP 是一种协议(protocol),它实现了 TCP 的一些思想,以通过不可靠的、基于数据包的接口(interface)提供可靠的数据
我正在尝试展开一些嵌套循环,以牺牲内存为代价(可能)获得更好的性能。在我的场景中,我最终会得到一个包含大约 3 亿个元素(元组)的列表,我必须以(或多或少)随机顺序产生这些元素。 在这个数量级上,ra
如何在 PHP 中生成(伪)随机字母数字字符串,例如:'d79jd8c'? 最佳答案 首先创建一个包含所有可能字符的字符串: $characters = 'abcdefghijklmnopqrstu
我有一段代码可以为玩家生成迷你任务。这很简单,要获得两个不同的点(起点和终点),我有一个如下所示的算法: std::vector missions; missions.push_bac
我是一名优秀的程序员,十分优秀!