CSS Dynamische Navigation mit Hover - Wie Mache ich es im iOS Safari?
In meiner Website verwende ich ein CSS dynamisches Menü. Dies ist gut in desktop-Browsern, aber nicht auf iOS - (iphone, ipad, etc), da die touch-Oberfläche unterstützt nicht die :hover
selector.
Meine Frage ist: was ist der beste Weg der Unterstützung dieser auf iOS? (Im Idealfall entweder durch patchen mit ein paar CSS-oder Javascript-Code enthält, wird der vorhandene code funktioniert, anstatt die ganze Sache immer nur um eine iOS-Version)
Mein html sieht so aus
<ul id="nav">
<li>
Item 1
<ul>
<li><a href=''>sub nav 1.1</a></li>
<li><a href=''>sub nav 1.2</a></li>
</ul>
</li>
<li>
Item 2
<ul>
<li><a href=''>sub nav 2.1</a></li>
<li><a href=''>sub nav 2.2</a></li>
</ul>
</li>
<li>
Item 3
<ul>
<li><a href=''>sub nav 3.1</a></li>
<li><a href=''>sub nav 3.2</a></li>
</ul>
</li>
</ul>
Und die CSS-Datei wird diese
#nav li {
float:left;
padding:0 15px;
}
#nav li ul {
position: absolute;
width: 10em;
left: -999em;
margin-left: -10px;
}
#nav li:hover ul {
left: auto;
}
Ich habe eine jsfiddle dieses hier: http://jsfiddle.net/NuTz4/
Du musst angemeldet sein, um einen Kommentar abzugeben.
Lesen Sie diesen Artikel, vielleicht ist es eine Lösung für Sie 😉
http://www.usabilitypost.com/2010/05/12/css-hover-controls-on-iphone/
Auch JS-Lösung, entnommen aus: http://www.evotech.net/blog/2008/12/hover-pseudoclass-for-the-iphone/
In jQuery:
css:
$("#nav li").bind("touchstart", function(){ $(this).toggleClass("hover"); });