为什么粘性位置不适用于页脚

时间:2019-03-15 14:21:07

标签: sticky

我刚刚发现CSS中的位置粘性。我认为这真的很酷,不需要这种简单行为就可以编写JS函数。

所以,我想尝试一下。在下面的示例中,页眉一直停留在顶部,但是我不明白为什么页脚没有停留在底部:

body {
  height: 180vh;
  padding: 0;
  margin: 10px 0;
}

header,
footer {
  position: -webkit-sticky;
  position: sticky;
  padding: 10px;
  color: #ffffff;
  text-align: center;
}

header {
  top: 0;
  background-color: brown;
}

footer {
  bottom: 0;
  background-color: #2d3142;
}
<header>I'm sticking to the top of the page</header>
<footer>I'm sticking to the Bottom of the page</footer>

那是为什么?

1 个答案:

答案 0 :(得分:-1)

我不确定是否发粘,但是如果您要做的只是将页脚放在底部,则可以尝试此操作。

if usersnames_flag == "ON":
print '<h1> History of All Clients Ever </h1>'
macraw = []
for user in c.get_users():
    macraw.append(user.get('mac'))

count = 0
x = 0

while (count < len(macraw)):
    client_list = c.get_client(macraw[x])
    raw_tx = float(client_list.get("tx_bytes"))
    byte_to_gb = raw_tx / 10**9
    byte_to_mb = raw_tx / 10**6
    readable = time.ctime(client_list['first_seen'])
    readable1 = time.ctime(client_list['last_seen'])
    if byte_to_gb > 1:
        print '<b>%s</b> with MAC <b>%s</b> first seen: <b>%s</b> last seen: <b>%s</b> total download usage --> <b>%s</b> GB' % (client_list.get('hostname'),client_list["mac"],readable,readable1,round(byte_to_gb, 2))
    else:
        print '<b>%s</b> with MAC <b>%s</b> first seen: <b>%s</b> last seen: <b>%s</b> total download usage --> <b>%s</b> MB' % (client_list.get('hostname'),client_list["mac"],readable,readable1,round(byte_to_mb, 2))
    count = count + 1
    x = x + 1
    print '<br/><br/>'