带有长文本的粘页脚

时间:2018-07-04 10:06:21

标签: html css

我的页面上有很长的文字。我希望页脚停留在底部,并且文本应隐藏在页脚下方,以便滚动文本。页脚下不应有文字。我怎样才能做到这一点?

<p>Enter Amount Here:</p>
<input type="text" name="value"></input>
<button class="button" onClick="computation()">Calculate!</button>
<p>Final Amount</p>
<div class="output">
    <output for="roundedNumber" name="finalAmount"></output>
</div>
.container {}
  footer {
        position: absolute;
        bottom: 0;
       }

1 个答案:

答案 0 :(得分:5)

您应该通过使用fixed位置而不是absolute

来实现此目的

.container {
  padding-bottom: 40px;
}
  footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: black;
  color: white;
  padding: 10px 0;
   text-align: center;
}
<div class="container">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>

<footer>Footer Here</footer>