-2

I have a group of columns that need to be centred inside a container div with a background colour of #eeeff3 so that when you zoom out the columns stay the same size and centred and the grey background stays 100% width.click the link to see the current html and css! jsfiddle

Can anyone shed some light on the situation?

jsfiddle links require code
Andy-Pandy
  • 37
  • 5

3 Answers3

4

Remove float:left and add display:inline-block.

See updated jsfiddle

.container{
     margin:0 auto;
     background: #eeeff3;
     width:100%;
     height:400px;
     text-align:center;
}
.col4{
    width:270px;
    height:400px;
    border-right:2px solid white;
    display:inline-block;
}
zoranc
  • 2,410
  • 1
  • 21
  • 34
SajithNair
  • 3,867
  • 1
  • 17
  • 23
  • 1
    +1 Also mind the [gap between inline(-block) elements](http://stackoverflow.com/questions/21875226/space-between-nowrap-inline-blocks/21875532#21875532). – Hashem Qolami Mar 10 '14 at 12:03
1
.container{
     margin:0 auto;
     background: #eeeff3;
     width:100%;
     height:400px;
     text-align:center;
}
.col4{
    width:270px;
    height:400px;
    border-right:2px solid white;
    display:inline-block;
}
0

Try this css work well:

.container{
     margin:0 auto;
     background: #eeeff3;
     width:100%;
     height:400px;
     text-align:center;

}
.col4{
    float:left;
    width:270px;
    height:400px;
    border-right:2px solid white;
    display:inline-block;
}
Mr.G
  • 3,413
  • 2
  • 16
  • 20