【问题标题】:How do I switch div's without messing it up?如何切换 div 而不会弄乱?
【发布时间】:2014-07-11 00:37:14
【问题描述】:

我想将“类别”部分放在“最近的帖子”部分上方,但不会搞砸,但我遇到了麻烦。有什么建议吗?

 <div align="center"> 
  <h3>Recent Articles</h3> </div>
  <ul id="posts">
    {% for article in blog.articles  %}
    <li><a href="{{article.url}}">{{ article.title }}</a>
      <p>{{ article.published_at | date: "%b %d %Y" }}</p>
      {{ article.excerpt_or_content }}
      <p>{{ article.content | strip_html | truncate: 100 }}</p>
    </li>
    {% endfor %} 
    <div align="center"> 
      <h3 style="margin: 20px 0">Categories</h3> </div>
    {% for tag in blog.all_tags %}
    <li class="tags">
      <a href="{{ shop.url}}/blogs/{{ blog.handle }}/tagged/{{ tag | handleize }}">{{ tag }}</a>
    </li>


    {% endfor %} 
  </ul>
</div>

【问题讨论】:

    标签: html shopify


    【解决方案1】:

    鉴于标签 {% %} 最有可能用于 Shopify 网站 - 它们必须与 html 块一起移动。以下代码将起作用:

    <div align="center"><h3>Categories</h3></div>
    <ul id="posts">
        {% for tag in blog.all_tags %}
        <li class="tags">
          <a href="{{ shop.url}}/blogs/{{ blog.handle }}/tagged/{{ tag | handleize }}">{{ tag }}</a>
        </li>
        {% endfor %} 
    
        <div align="center"><h3 style="margin: 20px 0">Recent Articles</h3></div>
        {% for article in blog.articles  %}
        <li><a href="{{article.url}}">{{ article.title }}</a>
          <p>{{ article.published_at | date: "%b %d %Y" }}</p>
          {{ article.excerpt_or_content }}
          <p>{{ article.content | strip_html | truncate: 100 }}</p>
        </li>
        {% endfor %} 
    </ul>
    

    您给出的代码最后还有一个额外的&lt;/div&gt; 标签,在这种情况下不需要,所以我删除了它。

    【讨论】:

    • 尝试将额外的&lt;/div&gt; 标签添加回上述代码的末尾。如果这不能解决问题,则问题可能出在应用的 CSS 样式中。
    猜你喜欢
    • 2017-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-04
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多