Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background color doesn't apply to whole page Vue.js [duplicate]

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?

like image 355
Desiigner Avatar asked Dec 11 '22 03:12

Desiigner


2 Answers

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

like image 114
laruiss Avatar answered Dec 14 '22 23:12

laruiss


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
}
like image 41
Zooly Avatar answered Dec 14 '22 23:12

Zooly