Bick
Bick

Reputation: 18531

how do I center the full page?

How do I center the full page ? I tried adding my object.css.css file:

#content {
  width: 700px ;
  margin-left: auto ;
  margin-right: auto ;

}

But that didnt help. I also tried:

.field
{
  margin:auto;
  width:70%;

}

But that didn't include h1 elements

Thanks. EDIT: https://i.sstatic.net/MeFSt.jpg

Upvotes: 0

Views: 2112

Answers (3)

valen
valen

Reputation: 845

To center content we first wrap the page in a div, then center the #content within that wrapper div.

your css would look like:

 #wrapper {
      width: 100%;
      height: auto;
 }
 #content {
      margin: 0 auto;
      width: 700px;
 }

your html would look like:

 <div id="wrapper">
     <div id="content">
        Content Stuffs
     </div>
 </div>

Upvotes: 1

andrunix
andrunix

Reputation: 1754

This isn't really a Ruby on Rails question as much as it is an HTML/CSS question. Your stylesheet should contain something like:

body {
    text-align: center;
}

And of course, whatever other content your layout contains can have other effects.

Upvotes: 2

Jared
Jared

Reputation: 12524

To center elements on the page you use margin:0 auto; and set a width but to center text within an element you would use text-align:center;

Upvotes: 1

Related Questions