2012-07-31 43 views
0

我正在为WordPress网站创建一个页面模板。为WordPress设置页面模板文件的页边距 - html和css?

在newpagetemplate.php目前,我有这个代码的文件,也只有这样的代码:

<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Copywriting for Serious Marketers</title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="keywords" content="copywriting, sales writing, marketing" /> 
<meta name="copyright" content="Copyright Richard Clunan. All rights reserved." /> 
<meta name="description" content="Advice on copywriting and marketing." /> 
<meta name="revisit-after" content="7 days" /> 
<?php 
/* 
Template Name: Salespage 
*/ 
?> 
    <div> 
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
      <?php the_title(); ?> 
      <?php the_content(); ?> 
     <?php endwhile; endif; ?> 
    </div> 
</head> 
<body> 
<body topmargin="100"> 
<body leftmargin="300"> 
<body rightmargin="300"> 
<body bottommargin="10"> 
</body> 
</html> 

如果我的理解是正确的,值我用设定利润的HTML代码。

而且,如果我的理解是正确的,那么我可以使用CSS代码。这,我认为:

body { 
     margin-top: 100px; 
     margin-right: 300px; 
     margin-bottom: 10px; 
     margin-left: 300px; 
    } 

如果我只是切换这些代码片段,新版本不应用边距。

为了使CSS代码有效,我需要做些什么?

并且是一种或其他类型的代码可能会导致在不同情况下出现问题的次数减少,例如在不同的浏览器上显示?

回答

0

您的标记有点超出有效范围。 :) 与PHP循环div应该在vody中,应该只有一个身体标记。我建议给你的循环div一个id,然后使用它作为CSS选择器,如下所示:

<?php 
/* 
Template Name: Salespage 
*/ 
?> 
<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Copywriting for Serious Marketers</title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="keywords" content="copywriting, sales writing, marketing" /> 
<meta name="copyright" content="Copyright Richard Clunan. All rights reserved." /> 
<meta name="description" content="Advice on copywriting and marketing." /> 
<meta name="revisit-after" content="7 days" /> 
<style> 
#content 
{ 
    margin: 100px 300px 10px; 
} 
</style> 

</head> 
<body> 
<div id="content"> 
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
     <?php the_title(); ?> 
     <?php the_content(); ?> 
    <?php endwhile; endif; ?> 
    </div> 
</body> 
</html>