CSS 弹出窗口是否会随着触摸屏的普及而消亡?

发布于 2024-11-02 09:35:13 字数 1100 浏览 0 评论 0原文

我正在设计一个网站(客户门户),将来可能会与移动/触摸屏设备一起使用。过去,我使用过这样的 CSS 代码:

div.Info
{
    display: inline;
    position: relative;
    text-decoration: none;
}

div.Info span.InfoDetail
{
    display: none;
}

div.Info:hover span.InfoDetail
{
    padding: 3px;
    display: block;
    position: absolute;
    top: 1em; left: 1em;
    border: 3px inset Gray;
    background-color: White; color: #000;
    text-align: left;
    white-space: nowrap;
    z-index: 25;
}

创建在鼠标悬停时显示的小 CSS 弹出窗口,它们似乎工作得很好。然而,我意识到这可能会或可能不会在触摸屏上工作,所以我想知道“正确”的行为是什么,因为我在有限数量的移动浏览器中发现似乎没有太多一致性能够看看。我查看了一下,似乎如果对象获得焦点,此悬停事件可能会激活,因此我在 http://mad-halfling.webs.com/testcode.htm 如果您将鼠标悬停在“鼠标悬停查看详细信息”文本或向上箭头的小图像上,则会显示一个小弹出窗口:-

  • 在 iOS 上(我在一家商店找到了一个演示 iPad 来测试它),这似乎不起作用(我只尝试了文本,因为我刚刚添加了图像)
  • 在我的 N900 上的 MicroB 上,点击文本和图像都会带来弹出窗口,
  • 在 Firefox(我相信是 Fennec)上很好,在我的 N900 上点击任何一个都没有任何反应,

您对此有何看法 - 这似乎是一种耻辱,因为它是一种无需求助于 javascript 即可制作弹出窗口的有用方法,但如果它今后将无法使用触摸屏我将不得不重新考虑我的策略

干杯

MH

I'm designing a site (a customer portal) that will probably be used with mobile/touchscreen devices at some point in the future. In the past I've used CSS code like this:

div.Info
{
    display: inline;
    position: relative;
    text-decoration: none;
}

div.Info span.InfoDetail
{
    display: none;
}

div.Info:hover span.InfoDetail
{
    padding: 3px;
    display: block;
    position: absolute;
    top: 1em; left: 1em;
    border: 3px inset Gray;
    background-color: White; color: #000;
    text-align: left;
    white-space: nowrap;
    z-index: 25;
}

to create little CSS popups that display on mouseover and they seem to work very well. However I'm conscious that this may or may not work on touchscreens so I was wondering what the "correct" behaviour was as there doesn't seem to be much consistency that I've found across the limited amount of mobile browsers I've been able to look at. I had looked about a bit and it seems that this hover event may activate if the object gains focus, so I created some test code at http://mad-halfling.webs.com/testcode.htm that displays a small popup if you mouse over the "Mouse over for detail" text or the little up-arrow image:-

  • on iOS (I found a demo iPad in a shop to test it) this doesn't seem to work (I only tried the text as I have only just added the image)
  • on MicroB on my N900, tapping the text and image both bring up the popup, fine
  • on Firefox (I believe it's Fennec) on my N900 tapping on either does nothing

What's your take on this - it seems a shame as it's such a useful way of making popups without having to resort to javascript, but if it won't work with touch-screens going forward I'm going to have to rethink my strategy

Cheers

MH

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我很坚强 2024-11-09 09:35:13

鼠标悬停的根本问题(包括将其用于桌面网站时)是没有 UI 指示行为。

这不是一个明确的答案,但我注意到,在您现在在移动设备上使用“鼠标悬停”的地方,您可以使用“长按”。但问题是用户界面上没有任何内容表明该行为。 (公平地说,没有任何指示的 UI 约定已经存在了一段时间,例如双击)。

经验法则可能仍然应该是,就像鼠标悬停一样,关键功能不应该需要它们。

The fundamental problem with mouseover, including when it is used for desktop websites, is that there is no UI indication of a behavior.

This isn't a definitive answer but I've noticed that in places where you would be using "mouseover" now on a mobile device you can use "long touch". The problem though is that nothing on the UI indicates that behavior. (To be fair UI conventions that have no indication have been around for a while, like double clicking).

The rule of thumb probably should still be that just like mouseovers, critical functionality shouldn't require them.

世界如花海般美丽 2024-11-09 09:35:13

为什么不在您想要弹出窗口的任何地方放置一个圆圈中的问号图像(这似乎是常见的习惯用法),并且具有 onhover 和 onclick 功能来显示您的文档?

Why not have a image of a question mark in a circle (which seems to be common idiom) near whatever you'd like a popup for, and have that have onhover and onclick functionality to display your documentation?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文