- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我尝试创建一个三态按钮:
在 Safari 桌面版和 Safari 移动版中,当添加按下状态时(通过 :active 伪状态)它会终止点击事件。
为什么这两个部分不能很好地结合在一起?
在此处演示的简单示例: https://jsfiddle.net/m7hev81t/1/
$('button').on('click',function(e){
$('#log').html('clicked ' + new Date().getTime());
});
button {
position:relative;
background:transparent;
border:none;
height:50px;
width:200px;
cursor:pointer;
}
button .state {
position:absolute;
width:100%;
height:100%;
display:none;
top:0; left:0;
}
.state.off { background:green; display:block; }
.state.on { background:orange;}
.state.down { background:red; }
button:hover .state.off, button:hover .state.down {display:none;}
button:hover .state.on {display:block;}
button.has-down:active .state.on, button.has-down:active .state.off {display:none;}
button.has-down:active .state.down {display:block;}
#log {
width:100%;
border:1px solid grey;
min-height:2em;
margin-top:2em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<p>
No down/click state.
</p>
<button>
<div class="state off">
off
</div>
<div class="state on">
on
</div>
<div class="state down">
down
</div>
</button>
<p>
Down/click state.
</p>
<button class="has-down">
<div class="state off">
off
</div>
<div class="state on">
on
</div>
<div class="state down">
down
</div>
</button>
<div id="log"/>
最佳答案
我认为问题在于状态本身正在捕捉点击事件。然后当状态隐藏时,点击不会冒泡。
添加这行 CSS 使其工作:
button.has-down .state { pointer-events:none; }
这是 fiddle :https://jsfiddle.net/m7hev81t/2/
完整示例,第二个按钮现在触发事件。
$('button').on('click',function(e){
$('#log').html('clicked ' + new Date().getTime());
});
button {
position:relative;
background:transparent;
border:none;
height:50px;
width:200px;
cursor:pointer;
}
button .state {
position:absolute;
width:100%;
height:100%;
display:none;
top:0; left:0;
}
.state.off { background:green; display:block; }
.state.on { background:orange;}
.state.down { background:red; }
button:hover .state.off, button:hover .state.down {display:none;}
button:hover .state.on {display:block;}
button.has-down .state { pointer-events:none; }
button.has-down:active .state.on, button.has-down:active .state.off {display:none;}
button.has-down:active .state.down {display:block;}
#log {
width:100%;
border:1px solid grey;
min-height:2em;
margin-top:2em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<p>
No down/click state.
</p>
<button>
<div class="state off">
off
</div>
<div class="state on">
on
</div>
<div class="state down">
down
</div>
</button>
<p>
Down/click state.
</p>
<button class="has-down">
<div class="state off">
off
</div>
<div class="state on">
on
</div>
<div class="state down">
down
</div>
</button>
<div id="log"/>
关于javascript - Safari 点击事件和激活状态不能共存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48106286/
我正在用 C 编写一个 shell,它应该支持后台和前台进程。 约束: 终止的后台进程应由信号处理程序捕获 没有全局变量可用于与信号处理程序进行通信 不允许列出进程/pids 我的解决方案: 等待 p
我目前有一个使用 Laravel Framework 使用 PHP/MySQL 构建的应用程序.我想将此应用程序迁移到 Ruby on Rails但我完全拆解/重建是不可行的。我想知道让一个 PHP
我需要使应用程序与所有 NET Framework 兼容:2、3、3.5 和 4。 此外,我想开发一个应用程序,当在仅安装了 Framework 2 的 PC 上执行时,GUI 是使用 Windows
我将在下一个项目中使用 GWT,但我想使用 JQuery 的一些非常好的小部件、组件(一些数据网格)。你觉得可能吗?谢谢! 最佳答案 虽然可以,但最好使用 gwtquery 。它是 JQuery 到
来自网上的定义: Karma: 是一种生成 Web 服务器的工具,该服务器针对连接的每个浏览器的测试代码执行源代码。针对每个浏览器的每个测试的结果都会被检查并通过命令行显示给开发人员。 Jasmine
我已经 read使用 Mono 开发的应用程序使用与 ART 类似的 MonoRuntime 进行部署,解释 C# 代码,执行它们等。我假设 Unity 和 Xamarin 都这样做。 对我来说奇怪的
我确实收到了一项具有挑战性的任务,即将旧的遗留 cakephp 2 应用程序迁移到 laravel 5.2。 两者必须共存并协同工作,同时所有模块都迁移到 laravel,因为它是一个大型应用程序。
我们这里有一个面向客户的大型 Web 应用程序。我们最近重写了在线购买体验,使其更快。我使用 ASP.Net-MVC 的建议没有被采纳,因为我是这里唯一知道这一点的人。 现在我们即将开始重新开发网站的
我总是看到更多的 Java Web 应用程序使用 ORM 框架将实体映射到数据库,并且显然使对象的序列化变得更容易。 这看起来不错,通常涉及很多代码,例如: @Entity @Table(name="
我尝试使用长按手势和配置为连续更新的步进器来设置 View 。长按时,不会出现步进器的连续特征。目前,我已禁用长按。我想我不需要它。但为了将来引用,我将如何允许两者共存? 需要明确的是,这是我尝试此操
我对 NodeJS 还很陌生,并计划为我当前的项目升级 NodeJS 版本。最新的 NodeJS LTS 是使用 NVM 安装的。 我需要不断在当前使用的 LTS 和已安装的新 LTS 之间切换。我知
有谁知道如何让这两个重载运算符共存? #include template class A; template std::ostream& operator& e ); template class A
是否可以在同一个集群中同时运行 Hadoop MR1 和 MR2(至少在理论上)? 如果是,我该怎么做? 最佳答案 理论上,你可以这样做: 在一台机器上运行 DataNode TaskTracker
我有一个遗留应用程序,它使用 spl_autload 来加载类(它们没有命名空间)
让 PHP7 和 PHP 8 共存 我已经从 PHP 7 升级到 PHP 8。就像 PHP 的情况一样,我在 /usr/bin 中仍然有 php7.4| (与 php8.0 一起)。但是,当我运行 p
在这个 Redux: Colocating Selectors with Reducers蛋头教程,Dan Abramov建议使用接受完整状态树而不是状态切片的选择器来封装远离组件的状态知识。他认为这
GCC 的两个版本可以共存: native Windows MinGW 版本和 cygwin linux 版本吗?当在 Cygwin 上系统尝试使用 MinGW 版本的 GCC 进行编译时,就会出现问
我的客户有一个 x64 服务器,他在其中安装了 x32 和 x64 版本的 Oracle 客户端。在他安装我的 Web 应用程序并尝试运行它后,他收到有关 Oracle.DataAccess.dll
我在安装了 IvyDE 的 Eclipse IDE 中运行 Ivy->Resolve 时遇到问题。同时, Ant 目标
我在一个基本上是一堆数据的文件存储库的网站上工作。 我需要人们能够通过 WebDAV 和他们的浏览器(即 mod_autoindex)遍历目录和下载文件。 仅使用 mod_autoindex 和 mo
我是一名优秀的程序员,十分优秀!