-4

So I've been designing some simple header bars for my website, and I've just noticed that I have an unexpected space in between nested divs in the bar.

Here's how it's been going.

HTML

    <body>
    <div class='main-container'>

        <div class='button'>
            <p> Issues </p>
        </div>

        <div class='button'>
            <p> Calendar </p>
        </div>

        <div class='button'>
            <p> Staff </p>
        </div>

        <div class='button'> 
            <p> Submit </p>
        </div>

    </div>
</body>

... with this CSS

.main-container {
    width: auto;
    height: 40px;
    float: left;
    vertical-align: middle;
    font-family: 'Arial';
    font-size: 12px;
    background-color: #fff;
    border: 1px solid #d3d3d3;
    }

.button {
    text-align: center;
    display: inline-block;
    height: 100%;
    width: 100px;
    // borders are to illustrate spaces
    border-left: 1px solid black;
    border-right: 1px solid black;
    }

.button:hover {
    background-color: #D3D3D3;
    }

and it looks like this (since I don't have enough reputation, I'll have to do a simple graphical representation):

| Issues | | Calendar | | Staff | | Submit |

Is there a way to remove the spaces in between the divs?

apizzimenti
  • 427
  • 2
  • 7
  • 19

2 Answers2

0

This is most likely due to to a margin on the body. A regular practice is to "reset" the inherited styles that every browser automatically adds.

This is a pretty common CSS reset.

Ramsay Lanier
  • 426
  • 6
  • 18
0

use float: left; for div button.

.button {
text-align: center;
display: inline-block;
float:left;
height: 100%;
width: 100px;
// borders are to illustrate spaces
border-left: 1px solid black;
border-right: 1px solid black;
}

I think it will solved your issue.

ketan
  • 19,129
  • 42
  • 60
  • 98