本文介绍了逃避大纲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直试图找出在被挂钩到较低级别标题后添加内容的最佳方式。

So I’ve been trying to figure out what is the best way to add content after a being hooked to a lower level title.

<section>
  <h1>Title of Section</h1>
  <h2>Related 1</h2>
  <h2>Related 2</h2>
     <p>I NEED THIS TO BE PART OF H1</p>
</section>

这是大纲中的内容:之后的任何内容h2 将与该特定部分相关。但是,我希望它能够逃脱 h2 并让它成为 h1 的一部分。

This is how it will come up on the outline: any content after the h2 will be related to that specific section. However, I would like it to escape that h2 and have it become part of the h1.

推荐答案

使用切片内容元素(部分文章一边 nav )明确地,这是无论如何:

Use sectioning content elements (section, article, aside, nav) explicitly, which is what the HTML5 spec recommends anyway:

所以你的代码片段看起来像:

So your snippet could look like:

<section>
  <h1>Title of Section</h1>
  <section>
    <h2>Related 1</h2>
  </section>
  <section>
    <h2>Related 2</h2>
  </section>
  <p>I NEED THIS TO BE PART OF H1</p>
</section>

p 元素现在属于标题部分标题。

The p element is now in scope of the heading "Title of Section".

(而不是部分,,如果其他三个分区内容元素中的一个是合适的,例如搁置。)

(Instead of section, consider if one of the other three sectioning content elements is appropriate, e.g., aside.)

这篇关于逃避大纲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 14:12