开发者

Making tappable HTML div for iPhone

In my HTML code, I got a <div>. When the user taps anywhere inside that div, I'd like to alter various properties, like text size and bac开发者_如何学Pythonkground color. To me, this sounds a lot like creating two CSS styles for each state sounds like it should work, so I created the following CSS:

div.tappable {
   background-color: red;
   font-size: 10pt;
}

div.tappable:active {
   background-color: green;
   font-size: 12pt;
}

For some reason, the :active style is never used. Am I doing something wrong?


i think this blog posting will be a good start to explaining how to track the events in moble safari and create the ui you are looking for

Touching and Gesturing on the iPhone


The :active selector is triggered for the duration in which the element is being pressed. However, on an iPhone, because of the nature of the touch screen, Mobile Safari doesn't use the :active selector.

To clarify, did you want to alter the properties while the user is pressing down on the div, or alter the properties after the user taps on the div?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜