在Tumblr中分隔帖子

时间:2015-10-29 21:03:43

标签: html css tumblr tumblr-themes

最近,我一直在尝试编写自己的Tumblr博客主题。现在,我已经掌握了HTML知识,并且在CSS中经验丰富。但是,我似乎无法将主题中的帖子分开。我使用的代码如下:

<!DOCTYPE html>
<html>
<head>
 <meta name="color:Background" content="#000000">
 <meta name="font:Body" content="Georgia" />
 <meta name="image:Background" content="http://i41.tinypic.com/wvztsk.png" />
 <meta name="color:Primary Colour" content="#03999b" />
 <meta name="color:Secondary Colour" content="#4cc3c5" />
 <link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
  <title>{Title}{block:PostSummary}, {PostSummary}{/block:PostSummary}</title>
 {block:Description}<meta name="description" content="{MetaDescription}" />{/block:Description}
 <link rel="shortcut icon" href="{Favicon}" />

<style type="text/css">

/* Header */
    .headerstuff {
    background-color: black;
    color: silver;
    height: 25px;
    width: 100%;
    text-align: center;
    text-decoration: none;
    font-style: italic;
    margin: -10px;
    padding-top: 12px;
    padding-bottom: -2px;
    position: fixed;
    font-family: 'Raleway', cursive;
}

body {
    background-color:{color:Background};
    font-family:{font:Body};
}

.links {
    color: red;
    text-align: left;
}    

#content {
    padding:10px;
    background-color: #000000;
    font-family: 'Raleway', cursive;
    font-size: 25px;
    max-width: 500px;
}

.contentcontainer {
    width:1480px;
    padding-left: 100px;
    padding-top: 50px;
}

#contentcontainer #content {
      background-color: white;
      width: 500px;
      margin: 0 auto 20px;
      padding:10px;
}

#content .title {
    font-family: 'Raleway', cursive;
    font-size:30px;
    color: silver;
    padding-left: 10px;
    border-bottom: 1px solid silver;
    text-align: center;
}

.text {
    color: white;
    font-size: 20px;
    font-family: 'Raleway', cursive;
    padding-left: 20px;
    font-style: italic;
}

</style>
</head>
<body>
<header>
<div class="headerstuff">"Welcome to Neverland!"</div>
</header>
<div class="contentcontainer">
<div id ="content">{block:Posts}

{block:Text}
{block:Title}<div class="title">{Title}</div>{/block:Title}
<div class="text">{Body}</div>
{/block:Text}





{/block:Posts}
</div>
</div>
</body>
</html>

到目前为止,我只编写了文本方面的内容,但正如您在屏幕截图中看到的那样,我似乎无法将这两个文本分成两个单独的框。有人帮忙吗? See that they are not separated?

1 个答案:

答案 0 :(得分:1)

每个帖子都会呈现{block:Posts}{/block:Posts}内的任何内容。

因此,要将每个帖子放在单独的DIV中,您的代码应该是类似的;

<body>

<header>
<div class="headerstuff">"Welcome to Neverland!"</div>
</header>

<div class="contentcontainer">

{block:Posts}

<div class="content">

{block:Text}
{block:Title}<div class="title">{Title}</div>{/block:Title}
<div class="text">{Body}</div>
{/block:Text}

</div>

{/block:Posts}

</div>

</body>

然后使用CSS margin.content在每个帖子之间留出一些空间。
另请记得在CSS中将#content更改为.content

有关更多帮助,请参阅documentation。还有一个示例主题的HTML标记,包含Tumblr目前支持的所有类型的帖子(Answer帖子除外)。

相关问题