簡體   English   中英

調整窗口大小時,防止網頁內容移動

[英]Keep Contents of webpage from shifting when window resized

我對html / css相當陌生,並嘗試構建一個簡單的網頁,但是當我調整瀏覽器窗口的大小時,元素會不斷變化。 例如,如果我在屏幕的右下角有文本,而我在瀏覽器窗口中有一個屏幕,那么我也想也必須向右滾動才能再次看到文本。 這是我的代碼無法正常工作:

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="utf-8" />
        <title>Test</title>
        <style>
            body {
                min-width: 960px;
                min-height: 960px;
            }
            #testxt {
                position: absolute;
                bottom: 10px;
                right: 20px;
            }
        </style>
    </head>

    <body>
        <div id="wrapper">
            <div id="testxt">Hello</div>
        </div>
    </Body>

</html>

我想在重新調整窗口大小時必須滾動查看以問好

如果要使其保持在固定位置,則必須給div左距離。

嘗試添加:

left: 1500px;

現在,調整窗口大小時,div不會水平更改位置。 要垂直進行相同操作,您還必須設置一個頂部。

希望這可以幫助!

嘗試將位置更改為固定。

具有固定位置的元素相對於瀏覽器窗口定位。

即使滾動窗口,它也不會移動:

#testxt
{
    position: fixed;
    bottom: 10px;
    right: 20px;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM