javascript 在页脚上方停止固定div

ih99xse1  于 2023-02-02  发布在  Java
关注(0)|答案(1)|浏览(100)

我有一个社会链接菜单固定在他的页面的左边,就像这样

<footer id="colophon"></footer>
<div>
   <nav>
    <ul id="social">
        <li>Link1</li>
        <li>Link2</li>
        <li>Link3</li>
    </ul>
    </nav>
</div>

还有css

#social{
   transform: rotate(-90deg);
   position: fixed;
   transform-origin: left;
   left: 50px;
   bottom: 22px;
}

现在有了页脚,我不希望菜单在页脚的顶部,而是应该停止在页脚上方。我该如何实现呢?我不想简单地改变底部位置,而是应该在22px,但停止在页脚上方。

nszi6y05

nszi6y051#

您可以在社交导航元素中添加一个margin-bottom,其高度等于页脚元素的高度,以确保它停在页脚上方。

footer#colophon {
  height: 100px; /* or the height of the footer */
}

#social{
   transform: rotate(-90deg);
   position: fixed;
   transform-origin: left;
   left: 50px;
   bottom: 22px;
   margin-bottom: 100px; /* or the height of the footer */
}

相关问题