0

In spite of setting all margins and padding to 0, I'm suddenly finding that processing my html & css using Prepros(also tried with XAMPP), is adding extra (unwanted) space under my last item ie. footer. While running the same html & css directly from Notepad++, does not do this (thankfully). Can someone please explain why this is happening since I will eventually be running from a local host. Here is the HTML:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf=8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <header>header</header>
    <div class="wrapper">wrapper1</div>
    <div class="wrapper">wrapper2</div>
    <footer>footer</footer>
  </body>
</html>

Here is the CSS:

html {
  margin: 0;
  padding: 0;
  border: 3px solid green;
}

body {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border: 3px solid lightblue;
  height: 100vh;
}


header {
  flex: 1;
  height: 50%;
  background-color: red;
  border: 3px solid black;
}

.wrapper {
  flex: 1;
  height: 20%;
  background-color: blue;
  border: 3px solid black;
}

footer {
  height: 5%;
  position: absolute:
  bottom: 0;
  background-color: orange;
  margin: 0;
  padding: 0;
}

Here are images of the same code running, first from file:/// and the other from localhost:

enter image description here

enter image description here

Would appreciate any clarification on this matter. NOTE: Above is the discrepancy in every browser i tried it on (Chrome, Firefox and Opera).

aorcsik
  • 15,271
  • 5
  • 39
  • 49
Agni Scribe
  • 252
  • 3
  • 18

1 Answers1

1

I think it's because you mentionned a position: absolute; for the footer. You shouldn't, because flex property does not apply anymore on the block. Try the use flex for each children items, like:

header, .wrapper{
  flex: 3;
}

footer{
  flex: 1;
}

It works for me.

KCarnaille
  • 1,027
  • 9
  • 18
  • thanks, tried this, but still ending up with the same issue – Agni Scribe Dec 10 '15 at 14:21
  • It's weird. Can I see the code you got now ? (with my solution) – KCarnaille Dec 10 '15 at 15:30
  • html: `
    header
    wrapper
    footer
    ` css: `html, body{ border: 2px solid green; } body{ display: flex; flex-direction: column; min-height: 100vh; } *{ margin: 0; padding: 0; } header, .wrapper{ flex: 3; background-color: blue; border: 2px solid black; } footer{ flex: 1; background-color: orange; }`
    – Agni Scribe Dec 10 '15 at 16:04
  • Alright thanks (next time with a jsfiddle please :) ) Does it give you the exactly same result then ? – KCarnaille Dec 10 '15 at 16:11
  • Sorry abt that - will jfiddle next time, it gives the same issue of unwanted space below the footer and outside the body/html. Also the consoler (through Chrome's developer tools) is showing these errors: 1.http://static.cmptch.com/v/lib/abchk.js?p=1&banner_id=23 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT 2. Mixed Content: The page at 'https://static.cmptch.com/v/lib/mng.html?105#180#360' was loaded over HTTPS, but requested an insecure image 'http://trcklion.com/suic?u=3332540220766735691'. This content should also be served over HTTPS. – Agni Scribe Dec 10 '15 at 16:17