How to eliminate the space at the top that my DIV leaves?

2

I have a DIV of leave a space between it and the top of the browser, see: link

CSS:

    .element {
position:relative;
display: table;
width:960px;
height:120px;
margin: 0 auto;
padding:0px;
background-color:#000000;
border:0px;
    }

I tried several things but without success. I need my DIV to stick glued to the top of the browser.

    
asked by anonymous 04.02.2016 / 19:04

3 answers

4

You can use the following css:

* {
margin: 0;
padding: 0;}
    
04.02.2016 / 19:08
0

Try to edit for:

.element{
  position:fixed;
  padding-top: 0px;
  margin-top: 0px;
}
    
04.02.2016 / 19:14
0

Try:

.element {
  margin-top: -20px;
  position: absolute;
  display: table;
  width: 960px;
  height: 120px;
  background-color: #000000;
  border: 0px;
}

Explanation:

This happens because the entire element has a 20px space with the top of the browser, and it's no use putting 0px , because there's > 20px between the div and the top of the browser.

I hope I have helped :)

    
07.02.2016 / 05:51