【问题标题】:What is the default value of the display-box in CSS display module level3?CSS显示模块level3中显示框的默认值是多少?
【发布时间】:2018-12-06 19:50:50
【问题描述】:

我正在考虑 CSS 显示模块级别 3 中即将推出的显示属性。它们应该使 Web 开发更容易。但我不明白如何正确使用显示框。 如果我使用代码 element.style.displayBox = 'none' 隐藏了一个元素,然后我想将其显示回来怎么办?设置值content 似乎不是我想要的。也许只是设置空字符串element.style.displayBox = ''

【问题讨论】:

标签: javascript css


【解决方案1】:

CSS 显示模块级别 3 不会将样式属性更改为 displayBox,它只是为 display 添加了更多选项,其中之一是 contents

您可以阅读更多关于它的信息here in the spec

这里你可以看到浏览器支持:

https://caniuse.com/#search=display-contents

演示

此演示将display 属性设置为none,然后在1.5 秒后将其设置为contents

setTimeout(() => {
  const box = document.getElementById('box');
  box.style.display = 'contents';
}, 1500);
#box {
  display: none;
}
<div id="box">
  <p>I appear after 1.5 seconds</p>
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-18
    • 2019-04-30
    • 2011-11-12
    • 1970-01-01
    相关资源
    最近更新 更多