5

I'm trying to apply background-color property to my Vue.js application. Since I want it to be displayed on all pages, I'm applying CSS directly to tag in index.html:

<head>
<style>
body, html {
  padding: 0;
  margin: 0;
  width: 100%;
}
body {
  background-color: black;
}
</style>
</head>

 <body>
   <div id="app"></div>
   <!-- built files will be auto injected -->
 </body>

So, as I see through the inspector, html doesn't cover the whole pageenter image description here

How to apply background-color to the whole page?

Desiigner
  • 2,136
  • 5
  • 26
  • 47

2 Answers2

10

This seems to be working:

<head>
<style>
body, html {
  padding: 0;
  margin: 0;
  width: 100%;
  min-height: 100vh;
}
body {
  background-color: black;
}
</style>
</head>

 <body>
   <div id="app">
     &nbsp;
   </div>
   <!-- built files will be auto injected -->
 </body>

Here the Codepen

laruiss
  • 3,780
  • 1
  • 18
  • 29
4

CSS rule is not applied because you didn't specified the height, but only the width.

body, html {
  padding: 0;
  margin: 0;
  width: 100%;
  min-height: 100%; // add this rule
}
Zooly
  • 4,736
  • 4
  • 34
  • 54