如何按百分比隐藏 css 的元素?

How to hide an element with css by with percentage?

我一直试图用 CSS 隐藏一个元素,但没有成功 我有这个代码:

  @media only screen and (max-width: 1180px)
  .element {display:none!important;}
  }

我尝试将宽度设为 60%,而不是 1180px

  @media only screen and (max-width: 60%)
  .element {display:none!important;}
  }

我一直在努力让它发挥作用,但我已经过了几天,我只是放弃并决定在社区寻求帮助,我知道我错过了一些东西......

您需要在媒体查询中使用 only 吗?参见 What is the difference between "screen" and "only screen" in media queries?

@media screen and (max-width: 1180px)
    .element {
        display: none !important;
    }
}

如果您的问题仍然存在,请提供有关您的问题的更多信息,因为此代码段中没有足够的信息可供使用。