Hi,

I am using bootstrap theme in drupal7. I simply like to place the entire site right in the center of the page. I can have about 20% margin in both sides of the screen.

Please see the link for the blocks/regions that I have. I have used the below css to place all the contents in the center. It did not work 100%.

Design.

body.html.front.logged-in.no-sidebars.page-node.page-node-.page-node-112.node-type-page.toolbar.toolbar-drawer {
    width: 70%;
    margin-left: auto;
    margin-right: auto;
}

Any help/recommendations please?

Comments

Sam Moore’s picture

Keep it simple.

body {
    width: 70%;
    margin: 0 auto;
}
Anonymous’s picture

Bootstrap comes with 2 css classes.

container

container-fliud

If you wrap your content inside

it should auto centre the main page for you so you don't really need to do anything more?
<div class="container">
  <div class="col-md-12">
  </div>
</div>

Or use offset, ie:

<div class="col-md-10 col-md-offset-1">
</div>

see: http://getbootstrap.com/css/

Sam Moore’s picture

@ drupalfriend123 - Your CSS selector, as written, will only work on node #112.

drupalfriend123’s picture

Thanks. I will give a try.

drupalfriend123’s picture

So far, I tried this.

body {
width: 70%;
margin: 0 auto;
}

It did not do much. Header which is in the navigation region worked. I had a menu block and about us block. I placed the menu block in top bar and the about us block in footer. Both of these are going outside the body.

I simply like to have two boxes: Box1 and Box2. Box1 is the main screen. I like to place box2 inside box1. All contents will go to box2. Box2 needs to be centered in box1. Any recommendation please?

Design

If you could provide some details, I would really appreciate it.

Sam Moore’s picture

You'll need to take a good hard look at your DOM and stylesheet to see why elements are appearing outside of the <body>.
<body> is meant to be the outside container for all visible elements on your page.
Are other visible elements actually outside the <body></body> tags in the DOM (they shouldn't be), or are some elements marked position:absolute (which takes an element out of the normal flow)?
Is there a public URL for your project?

drupalfriend123’s picture

Can you please help? URL

drupalfriend123’s picture

I was able to fix as follows:

In page tpl file, I had

<div class="main-container container">
<footer class="footer container myfooter">

After I removed container class from both, it worked. I do not why it worked but it worked. If you have better answer, please let me know.

Sam Moore’s picture

In your bootstrap css, the container class has certain fixed widths - that may have fouled up your layout.
Also your slideshow has certain elements deep inside its element structure that are marked position:absolute, and those may be messing with the slideshow layout in particular.