绝对位置在滚动条上没有固定位置

时间:2019-03-27 17:57:54

标签: html css position css-position absolute

所以我试图制作一个音乐应用,并在滚动时让自己的位置完全弄乱了整个布局

我尝试在互联网上搜索有关保持父母身份的信息:相对但没有用

我的HTML-

<div style="width:inherit;height:inherit;overflow:hidden" >
  <div class="ov" ><div><i style="font-size:2em;" class="fa fa-pause-circle"></i></div></div>

我的CSS-

.ov{

    width:12em;
    overflow: hidden;

    justify-content: center;
    text-align: center;
    flex-direction: column;

    border-radius: 15px;
    height: 12em;
    opacity:0.8;
    position: absolute;
    z-index:2;
    background-color: black;

}

它的外观-(https://imgur.com/sSPyUOr
滚动时的外观-(https://imgur.com/LteKyq6

2 个答案:

答案 0 :(得分:1)

如果您尝试使对象不滚动网站,请使用position:fixed;

Position:absolute只是根据最近的容器将一个对象与position:relative对齐。

答案 1 :(得分:0)

给出第一个div位置:绝对;最好先给它和id或class,然后再给.ov {position:relative};

.ov{

    width:12em;
    overflow: hidden;

    justify-content: center;
    text-align: center;
    flex-direction: column;

    border-radius: 15px;
    height: 12em;
    opacity:0.8;
    position: relative;
    z-index:2;
    background-color: black;

}
<div style="position:absolute;width:inherit;height:inherit;overflow:hidden" >
  <div class="ov" ><div><i style="font-size:2em;" class="fa fa-pause-circle"></i></div></div>

相关问题