【问题标题】:JS not working after doing custom css on Wordpress Site在 Wordpress 网站上进行自定义 css 后 JS 无法正常工作
【发布时间】:2015-05-07 12:05:45
【问题描述】:

我目前正在通过 wordpress 开发在线商店。一切正常,现在我想给我的页面一个自定义边框(倒圆角)并找到它的 css 代码,如下所示:

css:

body {
  background-color: #fff;
}

.wrapper {
  overflow:hidden;
  width:200px;
  height:200px;


}

div.inverted-corner {
  box-sizing:border-box;
  position: relative;
  background-color: #3e2a4f;
  height: 200px;
  width: 200px;
  border: solid grey 7px;
}

.top, .bottom {
  position: absolute;
  width: 100%;
  height: 100%;
  top:0;
  left:0;

}

.top:before, .top:after, .bottom:before, .bottom:after{
  content:" ";
  position:absolute;
  width: 40px;
  height: 40px;
  background-color: #fff;
  border: solid grey 7px;
  border-radius: 20px; 
}

.top:before {
  top:-35px;
  left:-35px;


}

.top:after {
 top: -35px;
 right: -35px;
  box-shadow: inset 1px 1px 1px grey;
}

.bottom:before {
  bottom:-35px;
  left:-35px;
}

.bottom:after {
 bottom: -35px;
 right: -35px; 
 box-shadow: inset 1px 1px 1px grey;
}

html:

<div class="wrapper">
<div class="inverted-corner">
<div class="top">&nbsp; </div>
  <h1>Hello</h1>
  <div class="bottom"> </div>
</div>
  </div>

我重命名了这些类,以免与主题的现有 css 类发生冲突。它工作正常,如下所示:my site。现在的问题是,我不能再与网站交互,没有链接,没有悬停效果。似乎自定义 css 覆盖了实际站点。你有什么建议我可能做错了吗?

附:我编辑了 header.php,使倒角 div 和顶部 div 位于页面包装器 div(网站内容)的正下方,在 footer.php 中,我编辑了顶部 div 和倒角 div 关闭在页面正上方 -包装器 div 关闭。

【问题讨论】:

  • DIV .bottom-corner 与您的所有站点重叠。设置pointer-events: none; 可以解决此问题,但旧版浏览器不支持此属性。
  • @Rob 你的意思是除了IEcaniuse.com/#feat=pointer-events

标签: javascript jquery css wordpress wordpress-theming


【解决方案1】:

添加:

pointer-events: none;

.bottom-corner CSS,所以鼠标通过。

【讨论】:

  • 请注意,这不适用于 IE10 或更低版本。 caniuse.com/#search=pointer-events
  • 哦,我忘了这个该死的 IE。搞砸仍在使用 IE 的人
  • 非常感谢。这条单行修复了它:D
  • 不错 :) 如果您对答案满意,请验证答案。 (对我来说,你验证的“答案”是诊断,但它根本没有解决方案。它只是告诉你你做错了什么,但没有解决问题。我的答案是修复。)
【解决方案2】:

在你的 custom.css 你有这个:

.top-corner, .bottom-corner {
  position: absolute;
  width: 100%;
  height: 100%;
  top:0;
  left:0;

}

这基本上覆盖了整个页面,因此禁用了任何交互。

【讨论】:

【解决方案3】:

我想建议更改以下 css 规则的另一个选项

CSS

.top-corner, .bottom-corner {
    position: absolute;
    width: 100%;
    height: 100%;
    top:0;
    left:0;
}

将上面的代码替换为下面的代码

.top - corner, .bottom - corner {
    position: absolute;
    width: 100 % ; 
}

此解决方案适用于所有现代浏览器和 IE8 及更高版本(我不确定 IE 的低版本,但它也可能适用于它们)

【讨论】:

    猜你喜欢
    • 2017-03-25
    • 2018-02-17
    • 2021-01-28
    • 1970-01-01
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 2022-06-15
    相关资源
    最近更新 更多