我正在構建一個簡單的反應應用程序。這是在渲染之後我的index.html:<html>元素大於<body>
<html><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello react!</title>
<link rel="stylesheet" href="./dist/styles/main.css" type="text/css">
</head>
<body>
<div id="App"><div data-reactroot="" class="navbar"><p>This will be the navbar</p></div></div>
<script src="./dist/components/main.js"></script>
<style>
body {
margin: 0;
}
</style>
</body></html>
唯一的裁決我在我的main.css文件至今:
.navbar{
background-color:blue
}
#App{
height:500px;
background-color:pink
}
什麼發生在我身上的標籤有一些空格之前開始。似乎我的html和body標籤上沒有邊距或填充,但是不是從頁面頂部開始,而是從較低的像素開始降低幾個像素...
所以<html>
是400x516px,而<body>
是400x500px。我希望身體完全填充html元素。
如果您需要更多信息,請詢問或結帳git repo。運行npm run start
在8080處打開服務器。
感謝您的幫助。