WordPress.org

Ready to get started?Download WordPress

Forums

editting page template - margins (7 posts)

  1. TheOrganicSister
    Member
    Posted 3 years ago #

    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>
    
    			<div class="entry-content">
    				<?php the_content(); ?>
    				<?php wp_link_pages('before=<p><strong>' . __('Pages:') . '</strong>&after=</p>'); ?>
    			<div class="clear"></div>
    			</div>
    
    		</div><!--.entry-->
    		<?php endwhile; ?>
    		<?php endif; ?>	
    
    	</div><!--#primary-->
    
    <?php get_footer(); ?>

    any help would be greatly appreciated.

  2. Josh
    Member
    Posted 3 years ago #

    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

  3. TheOrganicSister
    Member
    Posted 3 years ago #

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

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

  4. Josh
    Member
    Posted 3 years ago #

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

  5. TheOrganicSister
    Member
    Posted 3 years ago #

    here's a sample page (i've resized the column but it's all aligned to the left): http://theorganicsister.com/disclosur/

  6. TheOrganicSister
    Member
    Posted 3 years ago #

    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;">

  7. StandardExcellence
    Member
    Posted 2 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic