【问题标题】:Why is the element in the DOM despite being display: none?为什么尽管显示为 DOM 中的元素:无?
【发布时间】:2023-02-20 19:31:54
【问题描述】:
   <div class='ifx__alert-icon-wrapper'>
        <ifx-icon icon={this.icon}></ifx-icon>
   </div>

&__alert-icon-wrapper {
    display: none;
    &.show { 
      position: relative;
      min-width: 48px;
      display: flex;
      justify-content: center;
      align-items: center;
    }

DOM:

为什么 ifx__alert-icon-wrapper 元素尽管是 display: none 而在 DOM 中?

我肯定没有添加 show 类。

【问题讨论】:

标签: javascript html css stenciljs


【解决方案1】:

display: none 在应用于元素时删除元素中的内容。 display: none 没有将其从代码中删除或使其不可见。 display: none 可以添加到任何地方以删除它的外观。关于 display 的 mdn 文档和 display none 的信息可以在他们的 infromation about display: none 找到

【讨论】:

    猜你喜欢
    • 2021-12-09
    • 2020-02-21
    • 2016-10-17
    • 1970-01-01
    • 2017-09-04
    • 1970-01-01
    • 2023-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多