相对于块固定的位置,而不是视口

问题描述 投票:0回答:1

我有.gridster项目(块绝对定位,宽度和高度固定,并有溢出自动),在里面我想要红色块(绝对位于右下方)留在他在开始的地方,但是当我使用滚动,红色块跟随滚动。

.gridster-item {
    width: 400px;
    height: 200px;
    position: relative;
    overflow: auto;
    background-color: rgb(204, 214, 249);
}

.resizer {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background-color: red;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
</head>
<body>
    <div class="gridster-item">
        <div class="content">
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
            <p>Lorem Ipsun dolor amet</p>
        </div>
        <div class="resizer"></div>
    </div>
</body>
</html>
html css position css-position
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.