- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
好吧,这是用于文本的,这是我正在尝试的代码:
<style>
#items {
width:400px;
padding: 10px;
}
.esp {
float: left;
background-color: yellow;
position:relative;
z-index:0;
}
.le {
float: left;
position:relative;
z-index:0;
}
.esp:hover{
background-color: blue;
z-index:1;
/*width: 50px;*/
border: 20px solid;
}
</style>
<html>
<div id="items">
<span class="le">fist</span>
<span class="le">fist</span>
<span class="le">fist</span>
<span class="le">fist</span>
<span class="le">fist</span>
<span class="esp">second</span>
<span class="le">third</span>
<span class="le">fist</span>
<span class="esp">second</span>
<span class="le">third</span>
<span class="le">fist</span>
<span class="esp">second</span>
<span class="le">third</span>
<span class="le">third</span>
<span class="le">third</span>
<span class="le">third</span>
</div>
</html>
我正在寻找的是避免其他跨度的位移,似乎 z-index 属性不起作用。是这样的:
感谢您的帮助。
最佳答案
问题是您增加了 span 框的大小,但没有告诉其他元素忽略它。 relative
仅允许您相对定位 - 它不会从流程中移除,而 z-index
仅在元素显示在您的上方或下方时才执行某些操作 - 它不影响 x/y 定位。但是,我们需要将其设置得高于我们的弟弟妹妹,以便在他们面前显示我们的轮廓效果。
与边框宽度相同的负边距可以解决这个问题。
另一个更 DRY 的解决方案是使用 outline
或 box-shadow
而不是 border
,因为 outline
和 box-shadow
绘制在框外。
请注意,outline
也会在子项周围画出轮廓,因此如果您将任何子项绝对定位到他们在父项之外的位置,那么也会在他们周围绘制框。但是,对于您要尝试执行的操作,它在语义上是最正确的。
#items {
width:400px;
padding: 10px;
}
.esp {
float: left;
background-color: yellow;
position:relative;
}
.le {
float: left;
position:relative;
z-index:0;
}
/*border-neg-margins*/
/*dis: neg margins*/
.bnm:hover{
background-color: blue;
z-index:1;
border: 20px solid #556;
margin: -20px;
}
/*outline*/
/*adv: no negative margins, most semantically correct*/
/*dis: will expand to outline any children that exceed the parent's size*/
.ol:hover{
background-color: blue;
z-index:1;
outline: 20px solid #556;
}
/*box-shadow*/
/*adv: no neg margins, only outlines the box*/
/*dis: not really semantically correct*/
.bs:hover{
background-color: blue;
z-index:1;
box-shadow: 0 0 0 20px #556;
}
The first one uses Border and Negative Margins<br />
The second uses Outline<br />
The third uses Box-Shadow<br />
Color used is #556 so any sibling text appearing on top of it would be visible<br />
<span class="le">fist</span>
<span class="le">fist</span>
<span class="le">fist</span>
<span class="le">fist</span>
<span class="le">fist</span>
<span class="esp bnm">second</span>
<span class="le">third</span>
<span class="le">fist</span>
<span class="esp ol">second</span>
<span class="le">third</span>
<span class="le">fist</span>
<span class="esp bs">second</span>
<span class="le">third</span>
<span class="le">third</span>
<span class="le">third</span>
<span class="le">third</span>
关于html - 重叠跨度在悬停时没有位移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36701069/
如果此答案为 Kotlin,我想转换代码:https://stackoverflow.com/a/5402769/2735398 我将其粘贴到 Intellij 中: private int deco
对于这种转变: System.out.println(0b10000000_00000000_00000000_00000001>>>32); 我得到这个输出值: -2147483647 对吗? 最佳
如果没有大量工作,我想要的可能是不可能的,但也许有人有解决方案。我有一个像下面这样的图(这当然是一个过于简单的例子),其中我的刻度标签彼此非常接近: dd <- data.frame(x=1:4, y
试过这个代码on Go playground : package main import ( "fmt" ) func main() { log2Dim := uint32(9)
我希望在用户滚动时获取 UIScrollView 的位移,每次滚动时只需要位移。使用这个方法 -(void)scrollViewWillEndDragging:(UIScrollView *)scro
我正在检查我在装有 iOs 5.1 的 Ipad 中的应用程序当我点击 textarea 时,光标会跳到书写线上方两行。虽然焦点位于正确的位置,但光标的视觉外观出现在焦点线上方两行。对此有任何建议。
你如何获得像 -10 这样的数字?从这些移位练习题中? 据我了解X*32可以写成 x> 1 = 0001 0111 >> 1 = 000 1011 = 11 //right bit-shift by
我正在查看适用于 Linux 的开源 AMD GPU 驱动程序。我注意到一些我以前没有见过的东西,我想知道目的。在sid.h文件的第1441行,有一系列的定义是整数被左移0位。这不就是对原始整数进行操
这个网站 localhotchat.com 有文字从红色栏流出。我试过调整它,但它似乎并没有消失。 主页(和内部)上的 14pt 文本片段应该在 red_colored_strip 内,但它不是,并且
问题#1 在 Java 中,移位是否比使用单个语句将 移位相同数的代价高出数倍? 例如,是 int x = 5; x = x << 16; 比快 int x = 5; for (int i=0; i<
我有三个 Div,周围的 Div 是“MainDiv”,里面的 Top Div 是“UpperDiv”下一个是“FooterDiv”。 在 Mozilla 中一切正常,但在 Chrome 中“Foot
所以,我正在阅读一本关于 Go 的书(Ivo Balbaert 的 The Way to Go),其中有一个代码示例: const hardEight = (1 > 97 因为我没有在这台机器上安装
Android 平台提供了两类动画。 一类是Tween动画,就是对场景里的对象不断的进行图像变化来产生动画效果(旋转、平移、放缩和渐变)。 下面就讲一下Tweene Animations。 主要类:
我有 UINavigationItem,我想向它添加 UISearchBar。我是这样做的: let searchBar = UISearchBar(frame: CGRectMake(0, 0, s
本文实例讲述了Android动画之渐变动画(Tween Animation)。分享给大家供大家参考,具体如下: Android 平台提供了两类动画。 一类是Tween动画,就是对场景里的对象不断的
我在 C# 中使用 openCV 库中的 Lucas Kanade 光流算法;有一系列帧,我想在每两个帧中找出什么是光流并将其显示在图片框中。 我可以从以下函数中获取 velX 和 velY: Emg
我是一名优秀的程序员,十分优秀!