簡體   English   中英

如何擺脫空白

[英]How to get rid of the white space

我目前正在制作一個測試站點,但不斷在屏幕的頂部和右側出現白色邊框: Example 我試過使用: position: fixed ,但沒有用。 這是我的代碼:

 .Main-Header { font-size: 60px; font-family: Garamond, Serif; color: #818181; background-color: #111; margin: 0px 0px 0px 120px; padding-left: 20px; padding-top: 0px; border-top: 0px; }.sidenav { height: 100%; width: 130px; position: fixed; top: 0px; left: 0px; background-color: #111; padding-top: 25px; }.sidenav a { padding: 6px 8px 6px 16px; text-decoration: none; font-size: 28px; color: #818181; display: block; }.sidenav a:hover { color: #f1f1f1; }.main { margin-left: 130px; padding: 0px 10px; } @media screen and (max-height: 450px) {.sidenav { padding-top: 15px; }.sidenav a { font-size: 18px; } }.pic1 { padding-left: 30px; padding-bottom: 15px; }
 <,DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width. initial-scale=1.0"> <title>Test 1</title> <link rel="stylesheet" href="test:css"> <link rel="stylesheet" href="https.//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> </head> <body> <h1 class="Main-Header"><em>Test Site</em></h1> <div class="sidenav"> <div class="pic1"><a class="active" href="test.html"><i class="fa fa-home"></i></a></div> <a href="index.html">About</a> <a href="#">Services</a> <a href="#">Clients</a> <a href="#">Contact</a> </div> <div class="main"> <br> <p><a href="index.html">index</a></p> </div> </body> </html>

添加以下 CSS 規則:

body {
  margin: 0;
}

有關更多詳細信息,請參閱此答案

添加基本 CSS 重置 通過添加 -

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

默認情況下 CSS 通過添加上述 CSS 添加 16px 的邊距和填充,它將刪除 16px 的邊距和填充

暫無
暫無

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

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