为什么看不到HTML 5< dialog&gt ;? [英] Why can't I see HTML 5 <dialog>?

查看:88
本文介绍了为什么看不到HTML 5< dialog&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的Facelets文件:

Here is my Facelets file:

<!DOCTYPE html>
<html lang="en"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

<h:head>
    <title>Simple JSF Facelets page</title>
</h:head>

<h:body>
    Place your content here!
    <dialog>
        <dt>Sam</dt>
        <dd>Knock, Knock.</dd>
        <dt>Eric</dt>
        <dd>Who's there?</dd>
        <dt>Sam</dt>
        <dd>Justin.</dd>
        <dt>Eric</dt>
        <dd>Justin who?</dd>
        <dt>Sam</dt>
        <dd>Justin time for dinner!</dd>
    </dialog>
</h:body>
</html>

我在浏览器中看到的只是

What I see in the browser is only

将您的内容放在这里!

Place your content here!

当我检查该文件的源代码时,我看到的是chrome:

When I check the source for this file, I see in chrome:

<!DOCTYPE html>
<html lang="en"><head>
    <title>Simple JSF Facelets page</title></head><body>
Place your content here!
<dialog>
    <dt>Sam</dt>
    <dd>Knock, Knock.</dd>
    <dt>Eric</dt>
    <dd>Who's there?</dd>
    <dt>Sam</dt>
    <dd>Justin.</dd>
    <dt>Eric</dt>
    <dd>Justin who?</dd>
    <dt>Sam</dt>
    <dd>Justin time for dinner!</dd>
</dialog>
<ul id="javax_faces_developmentstage_messages" title="Project Stage[Development]: Unhandled Messages"></ul></body>
</html>

因此,从源代码看,它应该是有效的html5文件?但是目前,我看不到应该在dialog标记中的内容吗?

So, from the source code, it looks like it should be a valid html5 file? But currently, I can't see the content that should be in the dialog tag?

推荐答案

我以前从未使用过dialog标签,但是在检查了Chrome中内置的DOM和样式之后,似乎默认情况下该元素设置为display: none;

I have never used the dialog tab before, but after inspecting the DOM and styles built into Chrome, it seems as though by default the element is set to display: none;

dialog:not([open]){ display: none; }

因此要在您的页面上显示此内容,您需要设置样式;

So to display this on your page, you will need to set the style;

dialog{ display: block; }

更新

此外,您可以在dialog元素上使用open属性

Also, you can use the open attribute on the dialog element

<dialog open>....</dialog>

这篇关于为什么看不到HTML 5&lt; dialog&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆