How to "get rid" of vertical space between Divs?

Asked

Viewed 4,370 times

2

I’d like to get every piece of my website glued to each other, each in a different color. But I can’t get rid of the blank space that stays between the Ivs. I tried to remove the code space and apply font-size:0 (tips I saw on the internet) but it did not help. The two Ivs of different background colors should be attached to each other, here: https://jsfiddle.net/9byzo8cu/

  • 1

    The H2 tag and the "text" class are with set margins, so the white space between the Divs. Give an organized there in your style sheet. Example with pasted Divs: https://jsfiddle.net/9byzo8cu/3/

  • Thank you. I thought that because <H2> was inside the div "fundo1", only the styles of this div mattered !

  • 1

    H2 has this margin by default, you need to override the values or simply put a reset at the beginning of your css.

  • Thank you @Eduardokawanaka, direct and with valuable information for me ! Thank you =]

  • Problem-free =)

2 answers

3


Are the tags p and h2 that are causing the problem. If you add the code below in your , will note that spaces will be removed.

p, h2 {
  margin: 0;
} 

1

Try using a reset in your projects something like this:

* {
  margin: 0;
  padding: 0;
}

would solve your problem. If you want to know more about css-resets, read this article: http://tableless.com.br/css-reset/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.