
1 autoxbc 2021-08-27 21:17:56 +08:00 非标准方法有 @document,不过只能用在 Firefox 上 https://developer.mozilla.org/zh-CN/docs/Web/CSS/@document 我的处理方法是在 js 里加这么一句 document.body.setAttribute('location', location ); 然后就可以在 css 里进行地址查询 body:not([location*="123.com/?s="]) .test { display: none; } |
2 P233 2021-08-27 21:18:56 +08:00 借助 js 的话,方法还是很多的 纯 CSS 的话,就不那么优雅了: 1. 给 body 一个 id,例如 #body 2. url 加 hash, 如 123.com/?s=xxx#body 3. 更新 CSS 为 `:target .test { display: block }` |
3 wdssmq 2021-08-27 21:24:23 +08:00 .hidden { display: none; } <div class="test hidden">aa</div> 在搜索而额外加一段 <scripot> $("div.test").removeClass("hidden"); </scripot> 需要 JQ,虽然也有原生 JS 写法; 也可以通过判断决定要不要加 hidden 类,然而要看具体的前、后端渲染。。 |
4 orangejx 2021-08-28 09:48:14 +08:00 via iPhone 在搜索页加一段 css display:block |