繁体   English   中英

在注释部分放置断点或换行符(Python - Django)

[英]Putting break points or line breaks in the comment section (Python - Django)

更新 2

在查看 Bootstrap 材料后,我尝试使用<div class="row"> ,但评论似乎仍然呈现在一系列列中,而不是行中。

在此处输入图像描述

<article class="media content-section">
        <!-- comments -->
         <h2>{{ comments.count }} Comments</h2>
        {% for comment in comments %}

          <div class="row">
            <div class="media-body ">
                <a class="mr-2" href="#">{{ comment.name }}</a>
                <small class="text-muted">{{ comment.created_on|date:"F d, Y" }}</small>
            </div>

            <p class="article-content">{{ comment.body  }}</p>
          </div>





            {% endfor %}
      </article>

更新

这就是我的网站现在的呈现方式 - 在此处输入图像描述

似乎br没有做任何事情。

<article class="media content-section">
        <!-- comments -->
         <h2>{{ comments.count }} Comments</h2>
        {% for comment in comments %}

        <div class="media-body ">
            <a class="mr-2" href="#">{{ comment.name }}</a>
            <small class="text-muted">{{ comment.created_on|date:"F d, Y" }}</small>
        </div>
        <h3 class="article-title">{{ post.title }}</h3>
        <p class="article-content">{{ comment.body  }}</p>

        <br><br><br>
        <p>test2 test2</p>
        <br><br><br>
        <p>test2 test2</p>
        <br><br><br>

        {% endfor %}
  </article>

原帖

这就是我的网站呈现的方式 -

在此处输入图像描述

我尝试将<br></br>放在几个地方,但没有看到任何影响。 有没有人有任何想法?

<article class="media content-section">
        <!-- comments -->
         <h3>{{ comments.count }} Comments</h3>
         <br><br/>
        {% for comment in comments %}

        <div class="media-body ">
            <a class="mr-2" href="#">{{ comment.name }}</a>
            <small class="text-muted">{{ comment.created_on|date:"F d, Y" }}</small>
        </div>
        <br><br/>
        <h2 class="article-title">{{ post.title }}</h2>
        <p class="article-content">{{ comment.body  }}</p>
        <br><br/>

        {% endfor %}
  </article>

<br>标签是一个纯粹的 HTML 结构,我的意思是它非常低级。 这里还不够,您需要为您的数据分配适当的 css 类。

我可以看到您正在使用 boostrap css 框架,从 class 名称(如“col-md-8”)判断。 您还有一些其他自定义 css 类,例如“媒体内容部分”。

很难给你建议,因为我不知道那些自定义类是做什么的。 但是,引导程序使用网格系统并且有一个“行” class 用于新行。 试试看。

您可能正在修改您找到的一些示例,并且您可能删除了那里的评论的 rest 并在那里放置了一个 for 循环。 一般来说,您的方法是正确的,如果您这样做,请更加小心和专心。 我会恢复这些评论,看看你的代码有什么不同。

简而言之:

&#013;

br 标签的文本字符

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM