Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 当用户向上或向下滚动时,如何使表格随页面移动?_Html_Css_Html Table - Fatal编程技术网

Html 当用户向上或向下滚动时,如何使表格随页面移动?

Html 当用户向上或向下滚动时,如何使表格随页面移动?,html,css,html-table,Html,Css,Html Table,这就是我目前对一个表所做的,有没有一种方法可以让这个表在用户上下滚动时随页面移动 <table width="800" border="1" cell="" spacing="2" bgcolor="#336699"> <tr> <th width="0" bgcolor="#CCCCCC">Name</th> <th width="0" bgcolor="#CCCCCC">Toll Free N

这就是我目前对一个表所做的,有没有一种方法可以让这个表在用户上下滚动时随页面移动

<table width="800" border="1" cell="" spacing="2" bgcolor="#336699">
    <tr>
        <th width="0" bgcolor="#CCCCCC">Name</th>
        <th width="0" bgcolor="#CCCCCC">Toll Free Number</th>
        <th width="0" bgcolor="#CCCCCC">Toll Free Number International</th>
        <th width="0" bgcolor="#CCCCCC">Conference ID</th>
        <th width="0" bgcolor="#CCCCCC">Moderator Pin</th>
    </tr>
    <!-- more -->
</table>

名称
免费电话
国际免费电话
会议ID
慢化剂销

这个问题可以帮助您了解发生了什么: 基本上,正如有人评论的那样,您需要考虑添加到表中的元素。以下是一些有效的方法:

<table width="800" border="1" cell="" spacing="2" bgcolor="#336699">
        <tr>
            <th width="0" bgcolor="#CCCCCC">Name</th>
            <th width="0" bgcolor="#CCCCCC">Toll Free Number</th>
            <th width="0" bgcolor="#CCCCCC">Toll Free Number International</th>
            <th width="0" bgcolor="#CCCCCC">Conference ID</th>
            <th width="0" bgcolor="#CCCCCC">Moderator Pin</th>
        </tr>
        <!-- more -->
    </table>
    <div>
    </div>

小提琴:

这个问题可以帮助你弄清楚发生了什么: 基本上,正如有人评论的那样,您需要考虑添加到表中的元素。以下是一些有效的方法:

<table width="800" border="1" cell="" spacing="2" bgcolor="#336699">
        <tr>
            <th width="0" bgcolor="#CCCCCC">Name</th>
            <th width="0" bgcolor="#CCCCCC">Toll Free Number</th>
            <th width="0" bgcolor="#CCCCCC">Toll Free Number International</th>
            <th width="0" bgcolor="#CCCCCC">Conference ID</th>
            <th width="0" bgcolor="#CCCCCC">Moderator Pin</th>
        </tr>
        <!-- more -->
    </table>
    <div>
    </div>

fiddle:

假设您根本不使用CSS,设置一个“正常”html页面就足以获得所需的行为:

<html>
    <head></head>
    <body>
        <h1>some content</h1>
        <p>some other content</p>
        <div>
            <table width="800" border="1" cell="" spacing="2" bgcolor="#336699">
                <tr>
                    <th width="0" bgcolor="#CCCCCC">Name</th>
                    <th width="0" bgcolor="#CCCCCC">Toll Free Number</th>
                    <th width="0" bgcolor="#CCCCCC">Toll Free Number International</th>
                    <th width="0" bgcolor="#CCCCCC">Conference ID</th>
                    <th width="0" bgcolor="#CCCCCC">Moderator Pin</th>
                </tr>
        <!-- more -->
            </table>
        </div>
    </body>
</html>

一些内容
其他一些内容

名称 免费电话 国际免费电话 会议ID 慢化剂销

这将使表格与页面的其余部分一起滚动。因此,如果页面中的某个地方没有css定义使其具有粘性

假设您根本不使用css,那么设置“正常”html页面以获得所需的行为就足够了:

<html>
    <head></head>
    <body>
        <h1>some content</h1>
        <p>some other content</p>
        <div>
            <table width="800" border="1" cell="" spacing="2" bgcolor="#336699">
                <tr>
                    <th width="0" bgcolor="#CCCCCC">Name</th>
                    <th width="0" bgcolor="#CCCCCC">Toll Free Number</th>
                    <th width="0" bgcolor="#CCCCCC">Toll Free Number International</th>
                    <th width="0" bgcolor="#CCCCCC">Conference ID</th>
                    <th width="0" bgcolor="#CCCCCC">Moderator Pin</th>
                </tr>
        <!-- more -->
            </table>
        </div>
    </body>
</html>

一些内容
其他一些内容

名称 免费电话 国际免费电话 会议ID 慢化剂销

这将使表格与页面的其余部分一起滚动。因此,如果页面中的某个地方没有css定义使其具有粘性

,您可以将表格设置为css上的
位置:fixed
。这将使元素相对于视口进行定位

如果您没有CSS文件,您的代码将如下所示:

<table width="800" border="1" cell="" spacing="2" bgcolor="#336699" style="position:fixed;">
    <tr>
        <th width="0" bgcolor="#CCCCCC">Name</th>
        <th width="0" bgcolor="#CCCCCC">Toll Free Number</th>
        <th width="0" bgcolor="#CCCCCC">Toll Free Number International</th>
        <th width="0" bgcolor="#CCCCCC">Conference ID</th>
        <th width="0" bgcolor="#CCCCCC">Moderator Pin</th>
    </tr>
<!-- more -->
</table>

名称
免费电话
国际免费电话
会议ID
慢化剂销

我建议查看本教程以更好地了解基本定位:

您可以在CSS上将表格设置为
位置:固定。这将使元素相对于视口进行定位

如果您没有CSS文件,您的代码将如下所示:

<table width="800" border="1" cell="" spacing="2" bgcolor="#336699" style="position:fixed;">
    <tr>
        <th width="0" bgcolor="#CCCCCC">Name</th>
        <th width="0" bgcolor="#CCCCCC">Toll Free Number</th>
        <th width="0" bgcolor="#CCCCCC">Toll Free Number International</th>
        <th width="0" bgcolor="#CCCCCC">Conference ID</th>
        <th width="0" bgcolor="#CCCCCC">Moderator Pin</th>
    </tr>
<!-- more -->
</table>

名称
免费电话
国际免费电话
会议ID
慢化剂销

我建议查看本教程以更好地了解基本定位:

您的问题与Perl无关,而是与HTML和CSS有关。我将更改您的标记并相应地编辑问题。如果您想自己寻找解决方案,请不要考虑表格,而是考虑元素。您希望页面中的某个元素即使在滚动时也能保持在屏幕上的相同位置。这听起来像是让一个元素变得粘乎乎的。:)我想你是对的,这似乎更多的是我在寻找的,我只是不知道如何表达我的问题,谢谢你,尽管我会尝试!本着这些评论的精神。。。如果代码看起来不清楚,我真的无法显示更多内容,页面基本上是一个日历,我希望在用户上下滚动日历时,有一个信息表随光标移动。您的问题与Perl无关,而是与HTML和CSS有关。我将更改您的标记并相应地编辑问题。如果您想自己寻找解决方案,请不要考虑表格,而是考虑元素。您希望页面中的某个元素即使在滚动时也能保持在屏幕上的相同位置。这听起来像是让一个元素变得粘乎乎的。:)我想你是对的,这似乎更多的是我在寻找的,我只是不知道如何表达我的问题,谢谢你,尽管我会尝试!本着这些评论的精神。。。如果代码看起来不清楚,我真的无法显示更多内容,页面基本上是一个日历,我希望在用户上下滚动日历时,有一个信息表可以随光标移动。op希望opposite@LelioFaieta我现在明白了,在我写我的答案时,评论没有更新。虽然公平地说,陪审团仍然不清楚op想要什么:)op想要的是opposite@LelioFaieta我现在明白了,在我写我的答案时,评论没有更新。虽然公平地说,op想要什么,陪审团仍然没有决定:)