0

I have created a graph using CSS but i got some of troubles with inner divs (bar classes). There are white spaces between inner divs. I've tried by using float: left. it can remove white spaces, but inner divs are not adjacent to the bottom of outer div (graph class).

This is an example links (still not remove white space): http://dabblet.com/gist/2779082
Thank you

HTML

<div class="graph">
    <div style="height: 22px;" class="bar"></div>
    <div style="height: 11px;" class="bar"></div>
    <div style="height: 6px;" class="bar"></div>
    <div style="height: 49px;" class="bar"></div>
    <div style="height: 28px;" class="bar"></div>
</div>

CSS

.graph {
    width: 50px;
    height: 50px;
    border: 1px solid #aeaeae;
    background-color: #eaeaea;
}

.bar {
    width: 8px;
    margin: 1px;
    display: inline-block;
    position: relative;
    background-color: #aeaeae;
    vertical-align: baseline;
}
david
  • 3,225
  • 9
  • 30
  • 43
brendan
  • 19
  • 2
  • 8

6 Answers6

2

Add

.bar {
    padding:0;
    margin:0;
 }
Romain Braun
  • 3,624
  • 4
  • 23
  • 46
1
.bar {
    padding:0;
    margin:0;
 }

I am pretty sure that the white place will dissapear but because the border it is going to be another color. it takes 1px from each side of your div.

There always will be a margin between your div.

Daan Kleijngeld
  • 1,375
  • 2
  • 10
  • 13
0

Add padding: 0px; to your .graph

Joren
  • 3,068
  • 25
  • 44
0

Just add margin:0; to you bar css, spaces between your graphs are removed..You can see it in the image...

enter image description here

Sasidharan
  • 3,676
  • 3
  • 19
  • 37
0

You need to remove the white spaces really between the divs, Try the following instead of

<div class="graph">
    <div style="height: 22px;" class="bar"></div>
    <div style="height: 11px;" class="bar"></div>
    <div style="height: 6px;" class="bar"></div>
    <div style="height: 49px;" class="bar"></div>
    <div style="height: 28px;" class="bar"></div>
</div>

same exactly without spaces between divs

<div class="graph">
    <div style="height: 22px;" class="bar"/>
    <div style="height: 11px;" class="bar"/>
    <div style="height: 6px;" class="bar"/>
    <div style="height: 49px;" class="bar"/>
    <div style="height: 28px;" class="bar"/>
</div>
PhillyNJ
  • 3,859
  • 4
  • 38
  • 64
Adel
  • 1,468
  • 15
  • 18
0

I guess the reply is a bit too late for this quesiton, but the answer might help someone else who has the same problem.

In fact I am not answering this question, the answer is in the link below.

Why is there an unexplainable gap between these inline-block div elements?

Community
  • 1
  • 1
Adil
  • 105
  • 1
  • 4
  • 10