简体   繁体   English

具有焦点状态的CSS后代选择器在iOS中不起作用

[英]CSS descendant selector with focus state not working in iOS

I'm using the :focus state to show content, when the parent element has focus. 当父元素具有焦点时,我正在使用:focus状态显示内容。 Like so: 像这样:

.child { display: none; }
.parent:focus .child { display: block; }

Note that the parent element has tabindex="0" set. 请注意,父元素已设置tabindex =“ 0” Is there a way to get this to work in iOS browsers? 有没有办法让它在iOS浏览器中工作? I'm asking to see if a CSS-only solution is possible, no javascript please. 我想看看是否可以使用仅CSS的解决方案,请不要使用javascript。

I've set up a reduced test case fiddle here: http://jsfiddle.net/E8zCU/ 我在这里设置了简化的测试用例提琴: http : //jsfiddle.net/E8zCU/

An answer that worked for me for a similar problem is here. 对我来说,解决类似问题的答案在这里。

As the poster in that thread said, you just have to add 正如该主题中的发帖人所说,您只需添加

<body ontouchstart=""> 

to the top of your html code. 到您的html代码的顶部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM