重新出现固定位置元素

时间:2019-09-13 13:09:53

标签: html css css-position

我有一个fixed定位的元素。 CSS如下所示

header {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    padding: 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0);
}

enter image description here

如果我将位置static,元素将从屏幕上消失。如何重新显示该元素?

1 个答案:

答案 0 :(得分:1)

position: static与相对位置(topleftrightbottomz-index)不兼容,并将覆盖这些设置。您的元素将遵循正常的页面流程。

position: relative就像静态的一样,但是将保留这些设置。请注意,位置将相对于当前页面流。