简体   繁体   English

iPhone和iPad上的下拉菜单

[英]dropdown menu on iPhone and iPad

I have a working dropdown menu on my site, but it doesn't work at all on iPhone and iPad. 我的网站上有一个有效的下拉菜单,但在iPhone和iPad上根本无法使用。 Is there a manageable way to force iPhone/iPad to use their native menu selectors? 是否有一种可管理的方式来强制iPhone / iPad使用其本机菜单选择器?

http://jsfiddle.net/craigzilla/6nZ5Q/ http://jsfiddle.net/craigzilla/6nZ5Q/

HTML: HTML:

<div class="dropdown"> <span class="dropdown-toggle" tabindex="0"></span>
    <div class="dropdown-text" id="dropdown_colours">Colours</div>
    <ul class="dropdown-content" id="dropdown_colours">
        <li><a href="../black.html" target="_self">Black</a>
        </li>
        <li><a href="../grey.html" target="_self">Grey</a>
        </li>
        <li><a href="../red.html" target="_self">Red</a>
        </li>
        <li><a href="../blue.html" target="_self">Blue</a>
        </li>
        <li><a href="../green.html" target="_self">Green</a>
        </li>
        <li><a href="../purple.html" target="_self">Purple</a>
        </li>
    </ul>
</div>

I was thinking to the CSS property -webkit-appearance , but there is no value which could force the appearance to a select box AFAIK (if there were one, how could webkit know that it should treat the li as option ?) 我在考虑CSS属性-webkit-appearance ,但是没有任何值可以迫使外观出现在选择框AFAIK中(如果有的话,webkit怎么会知道应该将li视为option ?)

You have to use a select tag instead of an unordered list to make iOS' Webkit changing automatically its appearance to a native one. 您必须使用select标记而不是无序列表,才能使iOS的Webkit自动将其外观更改为本机。

You could detect when the user is using a mobile browser, and load your menu dynamically. 您可以检测用户何时使用移动浏览器,并动态加载菜单。

You could either find try to reproduce the native select box with CSS too, if you don't want to change your HTML markup... 如果您不想更改HTML标记,也可以尝试使用CSS重现本机选择框。

See Apple's documentation for reference. 请参阅Apple的文档以供参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM