Support » Themes and Templates » editting page template – margins

  • TheOrganicSister


    i’d like to edit my page-nosidebars.php template.

    currently it spans the whole page (920px)…i’d like to have the text span about 550px.

    i know how to change that within this line:

    <div id="primary" class="page" style="width:920px;">

    what i’m not sure how to do is change the margins of the text. i’d like to have it centered under the header instead of aligned to the left.

    how might i change that if my code looks like this:

    <?php /*
    	Template Name: No Sidebars
    */ ?>
    <?php get_header(); ?>
    	<div id="primary" class="page" style="width:540px;">
    		<?php if(have_posts()) : ?>
    		<?php while(have_posts()) : the_post(); ?>
    		<div class="entry" id="post-<?php the_ID(); ?>">
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    			<div class="entry-byline">
    				<?php edit_post_link('Edit', '[', ']'); ?>
    			<div class="entry-content">
    				<?php the_content(); ?>
    				<?php wp_link_pages('before=<p><strong>' . __('Pages:') . '</strong>&after=</p>'); ?>
    			<div class="clear"></div>
    		<?php endwhile; ?>
    		<?php endif; ?>	
    <?php get_footer(); ?>

    any help would be greatly appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Josh


    You’ll need to make that change in style.css

    add the following to the end of style.css

    .page-template-template-nosidebars-php #primary{
    text-align: center;

    should do the trick



    thanks for the input. i tried that but no luck.

    (i’m using a primepress theme, if that helps.)



    Knowing the theme helps, could you also provide a link to a page that is using the nosidebars template?

    here’s a sample page (i’ve resized the column but it’s all aligned to the left):

    okay i had a super amazing friend help me out. she added this line in the no-sidebar template and it’s working great:

    <div id="primary" class="page" style="width:600px; margin-left: 160px;">

    So, for clarification (I used this thread for reference today, and it was quite helpful), defining the “style” attributes in the <div> tag is one way to accomplish centering, but this will only take place on one page. If you re-use the “Primary” <div> section, these attributes will have to be deined again.

    The way to set this “globally,” so that every time you use <div id="primary">, you would need to edit your style.css file. Also, a pixel-specific definition will work fine for a fixed-width theme, but if your theme (or anyone’s for that matter) will expand with the browser window, 160 pixels might not be in the “center” for everyone’s screen. You could instead use <div id="primary" style="text-align: center;"> or put

    .page-template-template-nosidebars-php #primary{
    text-align: center;

    in your style.css file as Josh said. I hope that helps if anyone uses this in the future.

    Thanks Josh! Thanks TheOrganicSister, and thanks super amazing friend!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘editting page template – margins’ is closed to new replies.