gpt4 book ai didi

html - 允许重叠元素并避免位移

转载 作者:行者123 更新时间:2023-11-28 09:45:52 24 4
gpt4 key购买 nike

如果有人能提供一些帮助,我将不胜感激。

好的,我走了。

我做了这种自定义表格,使用一个 div 作为表格主体,一个嵌套的表格内容每个单元格都是一个跨度元素。一切都很好,但有一件事。

我尝试实现的是当用户将鼠标悬停在单元格(跨度)上时,如果内容太长(实际上很多)不适合宽度,它会自行弹出并以某种形式显示内容工具提示。

其实已经达到了目的,好吧,但是如果内容较大,单元格(跨度)会取代行的内容,这就是问题所在,如何避免这种行为?如何让内容与行的其余部分重叠并避免移位?

为了更好的解释检查这个 fiddle :http://jsfiddle.net/fuyn14en/2/

这是代码(与 fiddle 中的相同)。

HTML:

<div id="tabla">
<div id="tablaContenido">
<div class="tablaFila">
<span class="tablaFilaContenido">Short Content</span>
<span class="tablaFilaContenido">Laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrge Content makes the row displace how can i overlap so all other cells keep where they suppose to be?</span>
<span class="tablaFilaContenido">Short Content</span>
<span class="tablaFilaContenido">Short Content</span>
<span class="tablaFilaContenido">Short Content</span>
<span class="tablaFilaContenido">Short Content</span>
<span class="tablaFilaContenido">Short Content</span>
</div>
</div>
</div>

和 CSS:

#tabla{
width: 100%;
height: 100%;
display: table;
padding-bottom: 20px;
position: relative;
display: inline;
}

.tablaFila{
width: 100%;
height: 15px;
float: left;
display: table-row;
margin: 0;
border: 0;
padding: 0;
}

.tablaFilaContenido{
margin: 0;
border: 0;
padding: 5px 5px;
width: 11%;
white-space: nowrap;
float: left;
display: table-cell;
font-size: 10px;
overflow: hidden;
position: relative;
}

.tablaFilaContenido:hover{
background-color: #B2FF66;
content: attr(title);
z-index: 1;
display: block;
width: auto;
position: static;
}

如有遗漏或不清楚请追问:)

有什么想法或建议吗?

最佳答案

尝试这样的事情,

HTML

<head>
<link rel="stylesheet" type="text/css" href="7.css" />
</head>
<body>
<div class="tablaFila">
<span class="tablaFilaContenido">Short Content</p></span>
<span class="tablaFilaContenido">Laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrge Content makes the row displace how can i overlap so all other cells keep where they suppose to be?</p></span>
<span class="tablaFilaContenido">Short Content</p></span>
<span class="tablaFilaContenido">Short Content</p></span>
<span class="tablaFilaContenido">Short Content</p></span>
<span class="tablaFilaContenido">Short Content</p></span>
<span class="tablaFilaContenido">Short Content</p></span>
</div>


<body>
</html>

CSS

#tabla{
width: 100%;
height: 100%;
display: table;
padding-bottom: 20px;
position: absolute;
display: inline;

.tablaFila{

width: 100%;
height: 15px;
float: left;
display: table-row;
margin: 0;
border: 0;
padding: 0;

.tablaFilaContenido{

margin: 0;
border: 0;
padding: 5px 5px;
width: 11%;
white-space: nowrap;
float: left;
display: table-cell;
font-size: 10px;
overflow: hidden;
position: relative;

.tablaFilaContenido:悬停{

 background-color: #B2FF66;
content: attr(title);
z-index: 1;
display: inline;
width: auto;
position: absolute;

关于html - 允许重叠元素并避免位移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25253360/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com