{"id":275,"date":"2012-04-26T15:58:02","date_gmt":"2012-04-26T14:58:02","guid":{"rendered":"http:\/\/www.cotsweb.com\/blog\/?p=275"},"modified":"2012-04-26T15:58:02","modified_gmt":"2012-04-26T14:58:02","slug":"css-dropdown-menus-dont-work-on-iphones-ipads","status":"publish","type":"post","link":"https:\/\/www.cotsweb.com\/blog\/css-dropdown-menus-dont-work-on-iphones-ipads-275.html","title":{"rendered":"CSS Dropdown Menus don&#8217;t work on iPhones &#038; iPads"},"content":{"rendered":"<p>I have used CSS dropdown menus on quite a few sites, based on the Suckerfish idea. These have worked fine for a long time and with the addition of the <a title=\"Son of Suckerfish CSS Dropdown menus\" href=\"http:\/\/www.htmldog.com\/articles\/suckerfish\/dropdowns\/\">sfHover<\/a> function they work in IE as well as all more modern browsers. \u00a0But recently a client called me to say that the dropdowns weren&#8217;t working on her iPhone.<\/p>\n<h2>Making dropdown menus work on the iPhone<\/h2>\n<p>After a bit of trial and error and a lot of searching on the internet I discovered that the problem was that the iPhone (and I believe the iPad too) doesn&#8217;t honour the :hover \u00a0pseudoclass. \u00a0I was able to find a solution <a title=\"Tip for getting dropdown menus to work on the iPhone\" href=\"http:\/\/justtwonerds.com\/2010\/02\/24\/free-css-dropdown-menu-with-iphone-quick-tip\/\">here<\/a> and modified my code accordingly.<\/p>\n<p>All I had to do was add onmouseover=&#8221;&#8221; \u00a0to the li elements which contained ul elements for the dropdown menus. So;<br \/>\n<pre><code class=\"preserve-code-formatting\">\n&lt;li onmouseover=&quot;&quot;&gt;Top Level item\n&lt;ul&gt;\n&lt;li&gt;Dropdown item 1&lt;\/li&gt;\n&lt;li&gt;Dropdown item 2&lt;\/li&gt;\n&lt;\/ul&gt;\n&lt;\/li&gt;<\/code><\/pre><\/p>\n<p>&nbsp;<\/p>\n<p>This solved the problem and made the iPhone display the drop down menu when the top level element was touched. \u00a0A simple solution to a subtle problem.<\/p>\n<h2>But why doesn&#8217;t the iPhone work like everything else?<\/h2>\n<p>It seems that the reason Apple have done this is because you can&#8217;t actually hover on a touchscreen, which sort of makes sense until you think of the consequences. \u00a0And if you can&#8217;t hover why do they honour the mouseover event which is surely the same thing?<\/p>\n<p>One of the great things about smartphones is that they have good screens and good browsers so you can use the internet \u00a0reasonably well from a mobile device. \u00a0Unlike earlier attempts at mobile browsing,  like WAP, any well designed website will work properly on a smartphone. \u00a0You can design websites to take advantage of the smartphone&#8217;s extra capabilities but the vast majority of existing websites are navigable without changes. \u00a0If only sites designed from scratch for mobile use could actually be navigated by a smartphone they wouldn&#8217;t have access to very much at all and would lose one of their main attractions. \u00a0Apple have broken this; There must be quite large sections of some sites which are invisible to iPhone users.<\/p>\n<h2>And I mean EVERYTHING else!<\/h2>\n<p>All our websites are tested very thoroughly in lots of \u00a0browsers. \u00a0It isn&#8217;t possible to test every possible combination but we test in; Internet Explorer versions 6 through 9, Chrome, Firefox, Opera and Apple&#8217;s Safari.  This issue doesn&#8217;t appear in any of them, though of course we are not using a touch screen device with any these.  Even on <a href=\"http:\/\/www.electricplum.com\/products.html\" title=\"iPhone simulator\">Electric Plum&#8217;s iPhone simulator<\/a> the dropdown menus work fine. <\/p>\n<p>We don&#8217;t have a Mac so we can&#8217;t use Apple&#8217;s IOS simulator, I would be very interested to know if this problem is replicated there.  Significantly the problem does not seem to occur on Android phones, only Apple have taken this route.  I think they have made the wrong choice.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>I have used CSS dropdown menus on quite a few sites, based on the Suckerfish idea. These have worked fine for a long time and with the addition of the sfHover function they work in IE as well as all more modern browsers. \u00a0But recently a client called me to say that the dropdowns weren&#8217;t [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[33,103,22,118,28,18],"tags":[138,149,119,87],"_links":{"self":[{"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/posts\/275"}],"collection":[{"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/comments?post=275"}],"version-history":[{"count":8,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/posts\/275\/revisions"}],"predecessor-version":[{"id":283,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/posts\/275\/revisions\/283"}],"wp:attachment":[{"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/media?parent=275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/categories?post=275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cotsweb.com\/blog\/wp-json\/wp\/v2\/tags?post=275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}