右表始终在 XSL 的窗口中居中

Right Table centered always in window in XSL

本文关键字:窗口 中居 XSL      更新时间:2023-09-26

我尝试寻找这个答案,并看到接近它的问题,但无法解决我的问题@查看大表时,HTML表格标题始终显示在窗口顶部。

基本上,我们继承了一个具有 2 个 HTML 表的 XSL 页面,当您将鼠标悬停在主表上值为"yes"的行上时,它会在右侧显示与该行相关的隐藏的第二个表,而如果"否",则不显示任何内容。但是,如果通过 XSL 显示大量结果,则向下滚动时将无法看到该表。

我只是想知道是否有办法强制 1 右侧隐藏表每次将鼠标悬停在值上时都停留在屏幕顶部是,即使这意味着将 XSL 结果设置为具有滚动条?

希望我已经说清楚了,请参阅我遇到问题的代码摘录。

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<script>
function showme(show)
{
  <xsl:for-each select="root/Action">document.getElementById('<xsl:value-of select="@Type"/>').style.display='none';
  </xsl:for-each>
  document.getElementById('summary').style.display='none';
  document.getElementById(show).style.display='inline';
}
</script>
<xsl:for-each select="root/Action">
<span style="display:none">
 <xsl:attribute name="id"><xsl:value-of select="@Type"/></xsl:attribute>
 <table class="lgreenback"><tr class="small"><td class="green">Details for: <b><xsl:value-of select="@Type"/> Actions:</b> &#160; <a onmouseover="style.cursor='hand'" onclick="showme('summary')">&lt;&lt; Back</a></td></tr></table><br/>
 <table cellspacing="0" cellpadding="2" class="bdrnw">
 <tr class="small">
   <td class="lgheadercell">Date:</td>
   <td class="lgheadercell">&#160;</td>
   <td class="lgheadercell">Time:</td>
   <td class="lgheadercell">&#160;</td>
   <td class="lgheadercell">Done By:</td>
   <td class="lgheadercell">&#160;</td>
   <td class="lgheadercell">B&amp;S Ref:</td>
   <td class="lgheadercell">&#160;</td>
    <td class="lgheadercell">Assocs:</td>
 </tr>
 <xsl:for-each select="Case">
   <tr class="smallerstill">
   <xsl:choose>
   <xsl:when test="count(Linked) > 0">
     <xsl:attribute name="onmouseover">style.background='#f6f6f6', style.cursor='hand', document.getElementById('<xsl:value-of select="@id"/>').style.display='inline'</xsl:attribute>
     <xsl:attribute name="onmouseout">style.background='#ffffff', document.getElementById('<xsl:value-of select="@id"/>').style.display='none'</xsl:attribute>
   </xsl:when>
   <xsl:otherwise>
     <xsl:attribute name="onmouseover">style.background='#f6f6f6', style.cursor='hand'</xsl:attribute>
     <xsl:attribute name="onmouseout">style.background='#ffffff'</xsl:attribute>
   </xsl:otherwise>
   </xsl:choose>
     <td><xsl:value-of select="Date"/></td>
     <td></td>
     <td><xsl:value-of select="Time"/></td>
     <td></td>
     <td><xsl:value-of select="Realname"/></td>
     <td></td>
     <td><xsl:value-of select="substring(Client,1,3)" />-<xsl:value-of select="substring(Client,4,1)" />&#160;<xsl:value-of select="Ref"/></td>
     <td></td>
     <td align="center">
       <xsl:choose>
     <xsl:when test="count(Linked) > 0">Yes</xsl:when>
     <xsl:otherwise>No</xsl:otherwise>
   </xsl:choose>
 </td>
   </tr>
 </xsl:for-each>
</table>
</span>
</xsl:for-each>

</td><td valign="top" align="left">
<img src="../images/spacer.gif" height="41" width="120"/>
<xsl:for-each select="/root/Action/Case[count(Linked) > 0]">
  <span style="display:none">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<table cellspacing="0" cellpadding="2" class="bdrnw">
<tr class="small"><td class="lgheadercell">Assocs:</td></tr>
  <xsl:for-each select="Linked">
  <tr class="smallerstill"><td><xsl:value-of select="substring(@cl,1,3)" />-<xsl:value-of select="substring(@cl,4,1)" />&#160;<xsl:value-of select="@nm"/></td></tr>
  </xsl:for-each>
</table>
</span>
</xsl:for-each>
</td></tr></table>
</html>
</xsl:template>
</xsl:stylesheet>

如果您需要其他任何东西,请告诉我。

谢谢凯文

使用右侧表格上的 CSS position:fixed 属性,或在其周围使用

CSS 示例

#some-element {
  position: fixed;
  right: 0;
  top: 0%;
}

引用

  1. http://www.w3.org/Style/Examples/007/menus.en.html(给你的完美榜样!
  2. http://www.w3.org/wiki/CSS_absolute_and_fixed_positioning
  3. http://davidwalsh.name/css-fixed-position
  4. http://caniuse.com/css-fixed