簡體   English   中英

如何在背景圖像中刪除此頂部空間?

[英]How to remove this Top Space in the Background Image?

我使用一個簡單的HTML代碼將背景圖像設置到我的網頁,但它仍然顯示我在頁面頂部有一個空閑空間,我嘗試使用此代碼生活背景圖像,它被提升到了上面,可以你確認我,這是正確的方式還是我現有的CSS代碼有任何問題?

margin-top:-20px

我的CSS代碼,

<style>
.bg-image {
  left: 0;
  right: 0;
  height: 200%;
  background-image: url("/bg.jpg");
  background-position: 0px 0px;
  position: fixed;
  background-size: cover;
  margin-top:-20px;
}

我的HTML代碼:

<html>
<head> </head>
<body>
    <div class="bg-image"></div>
</body>
</html>

Body部分將調用內部分區,因此請確保Body Margins,如果我們設置body margin:0px; padding:0px; margin:0px; padding:0px; 那將觸及瀏覽器的頂部。

在CSS代碼中嘗試此代碼,

body{
    padding: 0px;
    margin: 0px;
}

暫無
暫無

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

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