gpt4 book ai didi

javascript - 需要解决方案以在不破坏布局的情况下公开表中的详细信息

转载 作者:行者123 更新时间:2023-11-30 06:39:03 25 4
gpt4 key购买 nike

我目前正在寻找一种解决方案,使我能够以紧凑、易于阅读的方式显示大量日志输出。目标是隐藏尽可能多的信息,直到它们变得有趣,因为我们需要显示数千行日志输出。

通过在 td 中引入 div,我已经成功地阻止了我们的表格宽度达到 2800 像素。现在我想在用户将鼠标悬停在 div 上时向用户公开完整信息,但不会破坏表格的布局,也不需要在代码中将所有信息重复两次,因为 html 已经接近 3-4 MByte。

可以使用 Javascript 和/或 JQuery,但我是新手,目前卡住了。

这是 html 代码的一个小的简化示例。

    <head>
<title>expose full details</title>
<style>
#codeline { width:150px; overflow:hidden; text-overflow: ellipsis; }
#fullline { background: #EEE; z-index: 10; display: hidden; }
#loglines { width:250px; overflow:hidden; text-overflow: ellipsis; white-space: nowrap;}
</style>
</head>
<body>
<table style="border:1px solid black;">
<tr>
<td>PASS</td>
<td>2012-10-10 09:30:31</td>
<td><div id="codeline">c:\myfiles\are\not\stored\here\testscript.py:line434</div></td>
<td><div id="loglines">Here is a very long log output that might continue for 10-20 lines</div></td>
</tr>
<tr>
<td>FAIL</td>
<td>2012-10-10 09:30:32</td>
<td><div id="codeline">c:\myfiles\are\not\stored\here\testscript.py:line439</div></td>
<td><div id="loglines">Here is another very long log output that might continue for 10-20 lines</div></td>
</tr>
</table>

感谢每一个提示!

谢谢!

最佳答案

重读一下,我在代码中有一个错字,在其中添加了一个额外的引号,我说澄清了 id 和类,我在那里说错了,当我说的是类时,我说的是风格......

首先,您需要了解一些事情。id="somename"应该是整个文档中的唯一值,如果你想对元素进行分组以使它们具有相同的样式,请使用 class="somename"并使用 .而不是 CSS 中的 #。

您不清楚要显示数据的确切位置,我相信这就是您想要做的,您可以使用#fullline 代码的绝对定位将其放在您想要的位置。我读到你发表的关于想要做这种工具提示样式的评论,你可以用绝对定位来做(在 showdtl 部分动态调整,但听起来你想要做文本的静态放置是最好的。我更改了整行的宽度,以便您可以看到它根据需要适当扩展。fullline 是我单独留下的代码中的唯一 id,以说明类和 id 的用法。我只是将它放在一起,它确实有效,但我相信它需要您进行一些调整才能获得所需的结果。

    <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>expose full details</title>
<style>
.codeline { width:150px; overflow:hidden; text-overflow: ellipsis; }
#fullline { background: #FFCC66; z-index: 10; width: 250; display: hidden; }
.loglines { width:250px; overflow:hidden; text-overflow: ellipsis; white-space: nowrap;}
</style>
</head>

<body>
<script>
function showdtl(passedobj){
fullline.style.display = '';
fullline.innerHTML=passedobj.innerHTML;
}
function hidedtl(){
fullline.style.display = 'none';
}

</script>
<table style="border:1px solid black;">
<tr>
<td>PASS</td>
<td>2012-10-10 09:30:31</td>
<td><div class="codeline">c:\myfiles\are\not\stored\here\testscript.py:line434</div></td>
<td><div class="loglines" onMouseOver="showdtl(this);return true" onMouseOut="hidedtl();return true" >Here is a very long log output that might continue for 10-20 lines</div></td>
</tr>
<tr>
<td>FAIL</td>
<td>2012-10-10 09:30:32</td>
<td><div class="codeline">c:\myfiles\are\not\stored\here\testscript.py:line439</div></td>
<td><div class="loglines" onMouseOver="showdtl(this);return true" onMouseOut="hidedtl();return true">Here is another very long log output that might continue for 10-20 lines</div></td>
</tr>
</table>

<div id="fullline">

</div>


</body>

关于javascript - 需要解决方案以在不破坏布局的情况下公开表中的详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12828577/

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