HTML table 作为背景?

HTML table as background?

我使用 html table 制作了一些元胞自动机动画,并希望将这些动画作为网页的背景。是否可以制作 table 页面背景?

虽然您当然可以在 table 上堆叠元素,但您不能像使用背景图片那样使用 table。如果您能举例说明您现在拥有的以及您正在努力实现的目标,那将会很有帮助。

是的,这绝对有可能。你想要做的是用 table 填充页面,方法是将其位置设置为绝对位置,强制其进入左上角,并将 width/height 值设置为 100%:

#your-table {
    position: absolute;

    /* Force table into the top right corner */
    top: 0px;
    left: 0px;

    /* Expand table out into the rest of the window */
    width: 100%;
    height: 100%;
}

如果设置pointer-events to "none," most browsers will prevent the cursor from changing when the user mouses over the content. There is also user-select, that can be used to disable text selection highlighting。因此,我建议将以下 CSS 规则添加到您的背景 table 中,使其表现得更像背景:

/* Disable pointer events */
pointer-events: none;

/* Disable text selection highlighting */
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
 -khtml-user-select: none; /* Konqueror HTML */
   -moz-user-select: none; /* Old versions of Firefox */
    -ms-user-select: none; /* Internet Explorer/Edge */
        user-select: none; /* Non-prefixed version, currently
                              supported by Chrome, Opera and Firefox */

祝你的项目好运!