1

I have the following code, with the html and body margins and padding set to zero, but their is still a gap at the top, why?:

enter image description here

CSS

html, body {
    margin: 0;
    padding: 0;
}

.mobile body {
    overflow: hidden;
}

.mobile #wrapper {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
}

.mobile #scroller {
    height: 3000px;
}


.header {
    background: url(../img/dark_exa.png) repeat;
    height: 300px;
    margin: 0 auto;
    text-align: center;
}

.header h1 {
    color: white;
}

HTML

<!doctype html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <title>Mobile Parallax with Stellar.js - Demo</title>
        <link rel="stylesheet" type="text/css" href="css/normalize.css" />
        <link rel="stylesheet" type="text/css" href="css/style.css" />
    </head>
    <body>

        <div id="wrapper">
            <div id="scroller">

                <div class="header">
                    <h1>Product Title</h1>
                </div>

            </div>
        </div>

        <script src="lib/jquery.min.js" ></script>
        <script src="lib/jquery.stellar.min.js"></script>
        <script src="lib/iscroll.js"></script>
        <script src="script.js"></script>
    </body>
</html>
Jamie Fearon
  • 2,574
  • 13
  • 47
  • 65

6 Answers6

4

Add margin: 0; to .header h1.

mrks
  • 8,033
  • 1
  • 33
  • 62
1

You've got .mobile written in your CSS but not in your HTML. This could be the issue as none of the CSS Is being applied

Kevin Lynch
  • 24,427
  • 3
  • 36
  • 37
1

add this in the css to make all your elements margins = 0

* { margin: 0; }
Ahmad Santarissy
  • 627
  • 6
  • 13
0

Your <h1> tag has a margin property assigned to it automatically, and this margin is creating the white "bar." If you remove the top margin, say with CSS like this...

.header h1 {
    margin-top:0;
}

...the white space should go away.

ASGM
  • 11,051
  • 1
  • 32
  • 53
0

This is because of h1 margin. Add the following 2 lines in .heading h1 and it will solve the problem.

.header h1 {
    margin: 0;
    padding: 21px 0;
}
Firoze Lafeer
  • 17,133
  • 4
  • 54
  • 48
razahassank
  • 195
  • 8
0

I use this way. It works for me.

.ui-bar-inherit{border:0px !important;}