2012-07-31 47 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>