Trammell
Trammell

Reputation: 57

Eliminate gap between HTML elements

I am trying to get this drop down menu to work but there is a space inbetween the header and the menu bar.

http://codepen.io/xdtrammell/pen/zneDa

Here is my css for the two containers:

.menu-bar {
  width:100%;
  background-color: #f50057;
  border-top-left-radius:10px;
  border-top-right-radius:10px;
}

.menu-drop {
  background-color:#212121;
  border-style: solid;
  border-color:#f50057;
  border-top:0px;
  border-width: 2px;
  border-bottom-left-radius:5px;
  border-bottom-right-radius:5px;
  width:99.6%;
  height:80px;
}

EDIT: We Fixed the gap of the elements but when using the toggle the gap still appears.

Upvotes: 3

Views: 87

Answers (3)

Adarsh Gowda K R
Adarsh Gowda K R

Reputation: 951

Here is updated code remove margin:10px from body or else make it as margin:0

CSS

* {
  margin: 0;
  paddin:0;

}

body {
  font-family: 'Roboto', sans-serif;
  margin:0px;
}

Upvotes: 0

Roko C. Buljan
Roko C. Buljan

Reputation: 206078

your .navicon is just trouble ;) here's a fix
and a Codepen demo

.navicon {
  /*float: right;*/
  height: 6px;
  width: 34px;
  margin-right:50px;
  border-top: 15px double #212121;
  border-bottom: 5px solid #212121;
  font-size: 0;
  /*position:relative;*/
  position:absolute; /* added */
  /*bottom:55px;*/
  right:6px; /* added */
  top:38px; /* added */
  cursor:pointer;
  transition: all .3s ease-in-out;
}

Upvotes: 2

Chris Deacy
Chris Deacy

Reputation: 265

Your h1 and your .button both have margins on the tops and bottoms of them.

I would suggest some sort of reset to set the margin of everything to 0 (This way, the only margins in play are ones defined by you).

I've added the following code. Here's the updated Codepen

* {
    margin: 0;
}

Upvotes: 0

Related Questions