我的页脚始终保持在底部。但是我注意到,当我滚动时,它会超出某些元素,但会超出其他看起来超奇的元素?我不明白为什么会这样?
footer {
background: linear-gradient(to right, #ffffff 0%, #000066 100%);
border-style: outset;
border-width: 10px;
border-color: #060675;
text-align: center;
font-size: 15px;
position: fixed;
bottom: 0;
height: 80px;
width: 100%;
}
我希望有一个包含所有内容的页脚。这是关于absolute
和relative
的定位。原因可能是某些元素相对放置,而我未指定,因此默认情况下它相对放置,但页脚位于上方而不位于下方。
我该怎么办?
您将需要添加处理CSS中各层的z-index。
footer {
background: linear-gradient(to right, #ffffff 0%, #000066 100%);
border-style: outset;
border-width: 10px;
border-color: #060675;
text-align: center;
font-size: 15px;
position: fixed;
z-index: 10; /* higher the number the more upper layer it will go*/
bottom: 0;
height: 80px;
width: 100%;
}