+ 5

How to make box fill screen with no margin?

It's offset by a few pixels, and margin:0px doesn't work. I want it to fill the full width and start at point 0 of the screen. How do I achieve that? Using div and css styling. https://code.sololearn.com/WhQ3Tl67tcVX/?ref=app

17th Jun 2018, 5:38 PM
Andre Daniel
Andre Daniel - avatar
6 Antworten
+ 6
.screen{ position: fixed; width: 100%; height: 100%; left: 0; top: 0; z-index: 10;// not need.. but when use more than one div and want what will front and what back background-color:blue; }
17th Jun 2018, 5:49 PM
Scooby
Scooby - avatar
+ 9
Andre Daniel put this bootstrap stylesheet inside your head tag : <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> or use this : html { overflow: hidden; } body { margin: 0 ; box-sizing: border-box; } html, body { height: 100 %; }
17th Jun 2018, 5:49 PM
***
+ 3
https://www.sololearn.com/learn/CSS/1118/ An element with greater stack order is always in front of an element with a lower stack order. you can remove that.. without code will run perfectly Andre Daniel
17th Jun 2018, 5:57 PM
Scooby
Scooby - avatar
+ 3
you can also use *{ margin:0; } or body { margin:0; }
17th Jun 2018, 7:53 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
Scooby what is z-index and why is it needed?
17th Jun 2018, 5:51 PM
Andre Daniel
Andre Daniel - avatar
+ 1
.screen{ position: fixed; width: 100%; height: 100%; left: 0; top: 0; z-index: 10; background-color:blue; }
24th Jun 2018, 9:05 AM
Alex
Alex - avatar