[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Pure CSS menu doesn't drop down on iphone/ipad safari but does on all PC browsers

Posted on 2011-10-27
3
Medium Priority
?
687 Views
Last Modified: 2012-05-12
I have a horizontal menu with dropdown options when you hover over the menu. It's just HTML and CSS, no JS or anything else. It works in IE, FF, Chrome and Safari on PC but on iPhone and iPad it doesn't drop down, probably because you cannot hover, only click. My skills in CSS aren't good enough to know why or to fix it - can someone help?

The URL is: http://www.mybetawebsite.co.uk/menu-test/
it's all in one file so you can view source and see the HTML and CSS.

Thanks Experts!!

/ Tobzzz
0
Comment
Question by:tobzzz
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
rbudj earned 2000 total points
ID: 37038410
You simply need to use onMouseOver="" on each drop down <li>

Try the code below. It works with iPhone.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Test</title>
<style type="text/css">
	/* Menu dropdown CSS */
	@charset "UTF-8";
	
	* html ul.dropdown li {
	 height: 1px;
	}
	
	ul.dropdown ul li,
	ul.dropdown-vertical {
	 margin-left: -16px;
	 mar\gin-left: 0;
	}
	
	ul.dropdown ul,
	ul.dropdown li:hover ul ul,
	ul.dropdown li:hover ul ul ul,
	ul.dropdown li:hover ul ul ul ul,
	ul.dropdown li:hover ul ul ul ul ul {
	 visibility: hidden;
	}
	
	ul.dropdown li:hover ul,
	ul.dropdown ul li:hover ul,
	ul.dropdown ul ul li:hover ul,
	ul.dropdown ul ul ul li:hover ul,
	ul.dropdown ul ul ul ul li:hover ul {
	 visibility: visible;
	}
	
	ul.dropdown ul ul ul ul ul ul {
	 visibility: hidden !important;
	}
	
	ul.dropdown,
	ul.dropdown li,
	ul.dropdown ul {
	 list-style: none;
	 margin: 0;
	 padding: 0;
	}
	
	ul.dropdown {
	 position: relative;
	 z-index: 597;
	 float: left;
	}
	
	ul.dropdown li {
	 float: left;
	 line-height: 1.3em;
	 vertical-align: middle;
	 zoom: 1;
	}
	
	ul.dropdown li.hover,
	ul.dropdown li:hover {
	 position: relative;
	 z-index: 599;
	 cursor: default;
	}
	
	ul.dropdown ul {
	 visibility: hidden;
	 position: absolute;
	 top: 100%;
	 left: 0;
	 z-index: 598;
	 width: 100%;
	}
	
	ul.dropdown ul li {
	 float: none;
	}
	
	ul.dropdown ul ul {
	 top: 1px;
	 left: 99%;
	}
	
	ul.dropdown li:hover > ul {
	 visibility: visible;
	}
	
	/** Next CSS imported bit **/
	
	ul.dropdown li.rtl ul {
	 top: 100%;
	 right: 0;
	 left: auto;
	}
	
	ul.dropdown li.rtl ul ul {
	 top: 1px;
	 right: 99%;
	 left: auto;
	}
	
	ul.dropdown {
	 font-weight: bold;
	}
	
		ul.dropdown li {
		 padding: 7px 20px 7px 20px;
		 background-color: #ce2b26;
		 color: #fff;
		}
	
		ul.dropdown li.hover,
		ul.dropdown li:hover {
		 background-color: #ae0011;
		 color: #fff;
		}
	
		ul.dropdown a:link,
		ul.dropdown a:visited	{ color: #fff; text-decoration: none; }
		ul.dropdown a:hover		{ color: #fff; }
		ul.dropdown a:active	{ color: #ffa500; }
		
		ul.dropdown ul {
		 width: 170px;
		 border-left:1px solid #ae0011;
		 border-right:1px solid #ae0011;
		 border-bottom:1px solid #ae0011;
		 left:-1px;
		}
	
			ul.dropdown ul li {
			 font-weight: normal;
			 border-bottom:1px solid #dd3a31;
			}
	
	ul.dropdown *.dir {
	 padding-right: 20px;
	 background-image: url(arrow-down.png);
	 background-position: 100% 50%;
	 background-repeat: no-repeat;
	 border-left:1px solid #ce2b26;
	 border-right:1px solid #ce2b26;
	}
	
	ul.dropdown *.dir:hover {
		border-left:1px solid #ae0011;
		border-right:1px solid #ae0011;
	}
	
	ul.classic {
	 list-style: disc;
	 margin-bottom: 1em;
	 padding-left: 2em;
	}
</style>
</head>

<body>

<ul id="nav" class="dropdown dropdown-horizontal">
	<li><a href="<%=PathModifier%>index.asp">Home</a></li>
	<li onMouseOver="" class="dir">Advice & Info
		<ul>

			<li><a href="#">Activities & Classes</a></li>
			<li><a href="#">Classes Discounts</a></li>
		</ul>
	</li>
	<li><a href="#">Awards</a></li>
	<li><a href="#">Blog</a></li>

	<li  onMouseOver="" class="dir">Meet Us
		<ul>
			<li><a href="#">About Us</a></li>
			<li><a href="#">Contact Us</a></li>
			<li><a href="#">News</a></li>
			<li><a href="#">Charity</a></li>
			<li><a href="#">Feedback</a></li>

		</ul>
	</li>
	<li><a href="#">Forum</a></li>
</ul>

</body>
</html>

Open in new window

0
 
LVL 11

Author Comment

by:tobzzz
ID: 37039047
That does work! What a simple solution. I'll award the points now but if you could reply with an explanation why that works I'd love to know, I like to learn as i go!

Thanks

/ Tobzzz
0
 
LVL 16

Expert Comment

by:rbudj
ID: 37039126
In a nutshell, the iPhone and iPad are set  by default to ingore hover CSS events, why? I'm not sure. But the override for this is by creating a onmouseover event handler.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question