CSS右下角的位置取决于页面高度



请参阅http://jsfiddle.net/2A3xZ/对于我面临的问题。滚动后,图像应位于的右下角,而不是第一次绘制的视口的右下角落。

使用

.someclass {
    position: relative;
}
.image {
    position: absolute;
    bottom: 0px;
    right: 0px;
}

然后由于某种原因,将div相互包含在一起是不起作用的(整个图像就消失了)。我在这里错过了什么?

使用position: fixed;而不是position: absolute;。下面是小提琴演奏:http://jsfiddle.net/VbV3P/

编辑:OP评论后:

你应该能够将position: relative;应用于你的身体。请参阅以下内容:

HTML:

<body>
<div class="corner">
    <img src="http://wtactics.org/wiki/images/2/2b/Box.png" />
</div>this
<br>is
<br>the
<br>site
<br>content
<br>which
<br>will
<br>cause
<br>the
<br>page
<br>to
<br>scroll
<br>vertically
<br>because
<br>of
<br>its
<br>amount
<br>of
<br>lines.
<br>that
<br>is
<br>expected
<br>behaviour
<br>and
<br>working
<br>as
<br>is
<br>should
<br>be.
<br>however,
<br>the
<br>box
<br>on
<br>the
<br>lower
<br>right
<br>corner
<br>should
<br>be
<br>at
<br>the
<br>current
<br>page's
<br>lowest
<br>corner
<br>depending
<br>the
<br>page's
<br>height,
<br>not
<br>just
<br>in
<br>the
<br>corner
<br>of
<br>the
<br>first
<br>drawn
<br>viewport.
<br>
</body>

CSS:

body {
    position: relative;
}
.corner {
    position: absolute;
    bottom: 0px;
    right: 0px;
}

这是最新的小提琴:http://jsfiddle.net/keW4P/

确保图像刚好在正文的结束标记之前。给它一个位置值:绝对;右:0;底部:0;

最新更新