为什么我的脚出现在中间的Flask里&jinja2

2024-09-30 01:32:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Flask/Jinja2块来创建HTML。我遇到了这个问题 我的脚注在中间。在内容较少或没有内容的页面中,它看起来不错(在底部)。我什么都试过了。在

以下是HTML和CSS:

h1, h2, h3, h4 { font-family: Sansita, serif } p { font-size: smaller } ul { position: relative; top: 25px; right: 25px } footer{ position: absolute; width: 100%; background: aliceblue; bottom: 0; height: 50px} ^{pr2}$


Tags: jinja2flask内容htmlposition页面h2h1
2条回答

你的问题是position: absolute。这将把项目准确地放在它所说的地方,即屏幕的底部。如果内容溢出,则页脚保持不变。你真正想要的是position: fixed

你的页脚在绝对位置。 所以使用位置:固定和将您的css构建为以下格式

footer {
   position:fixed;
   left:0px;
   bottom:0px;
   height:50px;
   width:100%;
   background: aliceblue;
}

如果你想要一个与IE6兼容的css别忘了这么做。在

^{pr2}$

您也可以删除页脚中的br。更喜欢在这个用例中使用填充顶部。干净多了。在

相关问题 更多 >

    热门问题