html5,段落内的图/图标题给出了不可预测的输出

发布于 2024-10-19 17:46:02 字数 2892 浏览 2 评论 0原文

以下标记使用figure元素来显示图像,该图像与段落文本内联——因此该图“包含”在第一个

内。

<div class="object-content"> 
    <p>
        <figure class="object-inline-figure"> 
            <img 
                class="object-inline-figure-image" 
                height="200"
                src="/site_media/media/files/images/WH-487_opt.jpeg"
                width="300"> 
            <figcaption class="object-inline-figcaption">
                <p class="object-inline-figcaption-caption">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
                <p class="credits">
                    <span>Credit:&nbsp;</span>
                    <span class="object-inline-figcaption-caption-user-credit">
                        <a href="/profiles/Grey-Smith-Leigh/">Leigh Grey-Smith</a></span>,&nbsp;
                    <span class="object-inline-figcaption-caption-custom-credit">Lady Grey</span>
                </p>
            </figcaption> 
        </figure>
        The relationships between functional drivers and symbolic power, 
        landscape and architecture, site and context, quality of materials 
        and quality of experience are all well considered. This high quality 
        design resolution can, in part, be attributed to the relationship 
        between designer and client.</p>
</div>

然而,这至少在 Chrome 和 Firefox 中似乎是有问题的,也就是说,当使用“inspect element”(在 Chrome 中)时,

文本/标记类似于:

<p></p>
<figure>
    #...
</figure>
The relationships between functional drivers and symbolic power, 
landscape and architecture, site and context, quality of materials 
and quality of experience are all well considered. This high quality 
design resolution can, in part, be attributed to the relationship 
between designer and client.
<p></p>

它有效地“孤立”了其

标记之外的文本“...之间的关系”,失去了其样式和语义。至少对于网站页面的浏览者而言。

移到

之外似乎会产生更可预测的结果,即:

<figure>
    #...
</figure>
<p>The relationships between functional drivers and symbolic power, 
landscape and architecture, site and context, quality of materials 
and quality of experience are all well considered. This high quality 
design resolution can, in part, be attributed to the relationship 
between designer and client.
</p>

但是当

向左或向右文本对齐

  • 这是
    (前一个示例)的正确使用吗?
  • 是浏览器的问题吗? (Safari/Firefox 和 Chrome 都会产生略有不同的、意想不到的解释)?
  • 正确的标记“应该”是什么?

The following markup uses the figure element to display an image, inline with the text of a paragraph -- hence the figure is 'included' inside the first <p>.

<div class="object-content"> 
    <p>
        <figure class="object-inline-figure"> 
            <img 
                class="object-inline-figure-image" 
                height="200"
                src="/site_media/media/files/images/WH-487_opt.jpeg"
                width="300"> 
            <figcaption class="object-inline-figcaption">
                <p class="object-inline-figcaption-caption">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
                <p class="credits">
                    <span>Credit: </span>
                    <span class="object-inline-figcaption-caption-user-credit">
                        <a href="/profiles/Grey-Smith-Leigh/">Leigh Grey-Smith</a></span>, 
                    <span class="object-inline-figcaption-caption-custom-credit">Lady Grey</span>
                </p>
            </figcaption> 
        </figure>
        The relationships between functional drivers and symbolic power, 
        landscape and architecture, site and context, quality of materials 
        and quality of experience are all well considered. This high quality 
        design resolution can, in part, be attributed to the relationship 
        between designer and client.</p>
</div>

However, this seems to problematic in at least Chrome and Firefox, that is, when using 'inspect element' (in Chrome), the <figure> and the <p> text/markup are reported to be like:

<p></p>
<figure>
    #...
</figure>
The relationships between functional drivers and symbolic power, 
landscape and architecture, site and context, quality of materials 
and quality of experience are all well considered. This high quality 
design resolution can, in part, be attributed to the relationship 
between designer and client.
<p></p>

Which effectively 'orphans' the text 'The relationships between...' outside of its <p> markup, losing its styling and semantic meaning... at least to the human viewer of the website page.

Moving the <figure> outside of the <p> seems to have more predictable results, i.e.:

<figure>
    #...
</figure>
<p>The relationships between functional drivers and symbolic power, 
landscape and architecture, site and context, quality of materials 
and quality of experience are all well considered. This high quality 
design resolution can, in part, be attributed to the relationship 
between designer and client.
</p>

But we kinda lose the 'textwrap' effect when the <figure> is text-aligned left or right.

  • Is this proper use of <figure> (the former example)?
  • Is the fault with the browser? (Safari/Firefox & Chrome all produce slightly different, unexpected interpretations)?
  • What 'should' the proper markup be?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

著墨染雨君画夕 2024-10-26 17:46:02

图元素是块级的,因此行为是正确的。允许的父标签是那些允许流程元素的标签 - http://dev.w3.org/html5 /markup/figure.html (例如 div、section、article...)

因此,figure 标签应放置在 p 标签之外。您可以将其浮动以允许包裹。

The figure element is block level and therefore the behavior is correct. Permitted parent tags are those that allow flow elements - http://dev.w3.org/html5/markup/figure.html (example div, section, article...)

Therefore the figure tag should be placed outside the p tag. You can float it to allow for wrap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文