div位置固定在可滚动div内,与滚动条重叠

时间:2016-11-30 08:30:08

标签: html position scrollbar fixed

我想在可滚动div中修正div的右侧位置 但是固定的div只是重叠了父div的滚动条!
如何解决?
您的回复将不胜感激 PS:我必须使用position:fixed来实现这一点。

.content{
    background:#ccc;
    width: 100%;
    height: 200px;
    margin:50px auto;
    position:relative;
    overflow-Y:auto;
}
.fixedmarker{
    background:#f00;
    color:#fff;
    position:fixed;
    width:100px;
    height: 100px;
    right: 0;
}

https://jsfiddle.net/p40p15j0/

1 个答案:

答案 0 :(得分:0)

如果我理解正确,您是否希望div中有一个带有滚动条的固定div? 就是这样,这是CSS代码:

.happy{
     background: #ccc;
     width: 100%;
     height: 200px;
     margin: 50px auto;
     position: relative;
     overflow-Y: auto;
    
}

.fixedmarker {
     background: # f00;
     color: #fff;
     position: fixed;
     width: 100px;
     height: 100px;
     right: 25px;
}

要查看我的项目版本: https://jsfiddle.net/Warthele/kqbyscpm/4/

相关问题