Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Center Forum Posts

From MoodleDocs
Revision as of 08:25, 17 June 2011 by Michael de Raadt (talk | contribs) (Created page with "{{Scrapbook}} == Center fixed width forum posts on the page == Set the '''width''' of the forum posts to a specific pixel value (or %). '''Center''' all posts (individual posts...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Center fixed width forum posts on the page

Set the width of the forum posts to a specific pixel value (or %). Center all posts (individual posts in in all modes) on the page. Not the text in the posting but the block of posts. The indents in threaded mode should be retained.

Also center the list of post titles (in threaded mode) as a block retaining their offset structure.

The basic page structure of the Moodle forum page looks like:

Moodle basislayout forum.gif

With the following CSS center all elements withing the #content div.

.mod-forum #content {
  text-align: center;
}

Then set the .forumpost, the .indent container and the .forumthread container to the given width and align their content to left. To make the elements stay in the center set left and right margins to "auto".

.mod-forum #content .forumpost {
  width: 620px; /*or 65%;*/
  text-align: left;
  margin: 10px auto 0;
}
.mod-forum #content .indent {
  min-width: 620px; /*65%;*/
  text-align: left;
  margin-left: 4%;
  margin-right: auto;
}
.mod-forum #content .forumthread {
  width: 620px; /*65%;*/
  text-align: left;
  padding-left: 8%;
}

In the editing area align the content to the left too.

#mod-forum-post #content .generalboxcontent {
  text-align: left;
}

Copy the complete CSS to the forum section of the file "styles_layout.css" in your theme folder:

.mod-forum #content {
  text-align: center;
}
.mod-forum #content .forumpost {
  width: 620px; /*or 65%;*/
  text-align: left;
  margin: 10px auto 0;
}
.mod-forum #content .indent {
  min-width: 620px; /*65%;*/
  text-align: left;
  margin-left: 4%;
  margin-right: auto;
}
.mod-forum #content .forumthread {
  width: 620px; /*65%;*/
  text-align: left;
  padding-left: 8%;
}
#mod-forum-post #content .generalboxcontent {
  text-align: left;
}