0

I have a layout similar to:

 <div>
    <table>
    </table>
</div>

I would like for the div to only expand to as wide as my table becomes. My CSS:

.content {
    text-align: center;
    height: auto;
    width: auto;
    -moz-border-radius:30px;
    -webkit-border-radius:30px;
    border-radius:30px;
    border: #solid 10px #000;
    background-color: rgba(105,100,100,0.8);
          }

I've tried adding display: inline-block it works but it sets my table to the left of the scree, here's the screenshot: image I want it to be centered as well, how do I do that?

Squidward
  • 131
  • 2
  • 14

3 Answers3

0

Add text-align: center to your body (provided the div is a direct child of your body tag)

body
{
    text-align: center;
}

(in your CSS stylesheet)

sodawillow
  • 11,431
  • 4
  • 34
  • 43
0

You could work with translate here.

.content{
    left: 50%;
    transform: translateX(-50%);
}
Frederik Witte
  • 1,067
  • 2
  • 9
  • 34
0

Add text-align: center to parent element of div with display:inline-block

Michał Kutra
  • 1,202
  • 8
  • 20