我的页面看起来是这样的:如何在父元素使用全屏伪元素时启用链接?
<div.ui-page>
<div.ui-content>
<a href="foo.html">
</div>
</div>
在我的页面,我设置全屏水印像这样:
/* Watermark */
.ui-page:before {
background: url("../img/foo.png") no-repeat center center;
position: absolute;
content: "";
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
/* transparency */
opacity: .2;
/* grayscale */
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
filter: gray;
-webkit-filter: grayscale(100%) brightness(10%) contrast(100%);
}
工作正常。问题是,我的链接不再可点击。
我试图:before
伪元件周围移动具有不同程度的z索引的沿。一切都不起作用。奇怪的是,这似乎只涉及基本的链接。包裹中的其他元素的任何链接做工精细(我使用jQuery Mobile的,所以链接说ul
里面工作)
问题:
我怎样才能保持一个普通的链接点击/可行的,如果父元素或包含链接的元素使用CSS伪元素?
谢谢!
解决方案:
这是我的最终代码。 注意,我只好改用ui-page-active
- 否则它只能在第一页上的jQuery Mobile的加载。
.ui-page-active:before {
background: url("../img/foo.png") no-repeat center center;
background-attachment: fixed;
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
/* transparency */
opacity: .2;
/* grayscale */
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
filter: gray;
-webkit-filter: grayscale(100%) brightness(10%) contrast(100%);
}
/* disable pointer events on the background... */
.ui-page.ui-page-active:before {
pointer-events: none;
}
不是工作,而是为链接非常感谢! – frequent
我更新了我的答案。 – stephenmurdoch
好主意。让我尝试。 – frequent