2

I have a table div that contains two cells. I want the cells to touch each other horizontally and to have an equal border on each side (appear centered within the outer DIV). Is there some way I can do this?

<div id='hdr_msg' style='display: table; border: 1px solid red; width: 200px;'>
   <div id='hdr_txt'>
      <div id="hdr_msg1" style='display: table-cell; border: 1px solid blue;'>Test</div>
      <div id="hdr_msg2" style='display: table-cell; border: 1px solid green;'>One</div>
   </div>
</div>

What I have now is that Test One appears to the left but I need it in the center.

Fiddle

Andy E
  • 338,112
  • 86
  • 474
  • 445
Samantha J T Star
  • 30,952
  • 84
  • 245
  • 427

1 Answers1

2

may be you write like this :

<div id='hdr_msg' style='display: table; border: 1px solid red; width: 200px;'>
   <div id='hdr_txt' style="display: table;margin:0 auto">
      <div id="hdr_msg1" style='display: table-cell; border: 1px solid blue;'>Test</div>
      <div id="hdr_msg2" style='display: table-cell; border: 1px solid green;'>One</div>
   </div>
  </div>

Check this http://jsfiddle.net/sandeep/bmtBU/3/

For more check Steven theory CSS way to horizontally align table

Community
  • 1
  • 1
sandeep
  • 91,313
  • 23
  • 137
  • 155