-1

I am not an Android developer, I am just creating a website with a dropdown menu. Now I was told that this website has to be compatible with mobile devices too. I use Wordpress for creating this website and when I used a widget for my menu, it did not work on Android devices. I created a new dropdown menu using CSS only and tested it again on my 2 Android devices. The menu has 2 levels. When level 1 is hovered (I know that hover is bad for mobile devices at all) level 2 is displayed usually. The menu items of both levels link to a subpage of the website when they are clicked.

On my Samsung Galaxy S2 with Gingerbread the CSS menu works okay but not perfect. When level 1 (e.g. called "Fruit" is clicked, the page "Fruit" opens but the subitems (e.g. "Apple" and "Banana") are displayed. If "Apple" or "Banana" is clicked, the appropriate page is called. The only problem is: If I am already on the "Fruit" page and i click on "Fruit" in the menu again, nothing happens. That's not good at all but it would be okay for me.

Unfortunaltely I really have problems with the menu on my Asus Transformer Prime tablet with Ice Cream Sandwich. When I click a level 1 menu item, the page for this item is displayed but the submenu cannot be clicked. It's shown for just one second while the page is loading. So there is no possibility to reach the subpages of the website on this device.

I hope I described my problem clear enough, whether I have no Android knowledge nor my English is perfect. Please let me know if I should provide any CSS or HTML code or whatever. Thanks for any advice and help!

This is my PHP, HTML and CSS code:

PHP:

    <div id="menu" role="navigation">
        <?php wp_nav_menu(array('sort_column' => 'menu_order', 'menu' => 'Categories', 'container_class' => 'main-menu-class',
                                'container_id' => 'main-menu-id', 'theme_location'  => 'header', 'show_home' => true)); ?>
    </div> <!-- menu -->

HTML (generated by the PHP):

<div id="menu" role="navigation">
<div class="menu">
<ul>
<li class="current_page_item">
<a title="Home" href="http://whatever.com/wordpress/">Home</a>
</li>
<li class="page_item page-item-40">
<a href="http://whatever.com/wordpress/?page_id=40">Cupcake Ipsum</a>
<ul class="children">
<li class="page_item page-item-388">
<a href="http://whatever.com/wordpress/?page_id=388">Red Velvet Cupcake</a>
</li>
<li class="page_item page-item-390">
<a href="http://whatever.com/wordpress/?page_id=390">Mango Cupcake</a>
</li>
<li class="page_item page-item-392">
<a href="http://whatever.com/wordpress/?page_id=392">Chocolate Cupcake</a>
</li>
</ul>
</li>
<li class="page_item page-item-43">
<a href="http://whatever.com/wordpress/?page_id=43">Bacon Ipsum</a>
<ul class="children">
<li class="page_item page-item-405">
</ul>
</li>
<li class="page_item page-item-45">
<a href="http://whatever.com/wordpress/?page_id=45">Veggie Ipsum</a>
<ul class="children">
<li class="page_item page-item-397">
<a href="http://whatever.com/wordpress/?page_id=397">Tomato</a>
</li>
<li class="page_item page-item-399">
<a href="http://whatever.com/wordpress/?page_id=399">Lettuce</a>
</li>
<li class="page_item page-item-401">
<a href="http://whatever.com/wordpress/?page_id=401">Broccoli</a>
</li>
<li class="page_item page-item-403">
<a href="http://whatever.com/wordpress/?page_id=403">Onion</a>
</li>
</ul>
</li>
</ul>
</div>
</div>

CSS:

.menu {
background-color: #0B5A7D;
display: inline-block;
position: relative; }

#menu .menu-header ul,
div.menu ul {
list-style-type: none;
width: 921px;
margin: 0;
padding: 0; }

#menu ul li a {
text-decoration: none;
color: #CCCCCC;
font-size: 16px;
padding: 10px;
display: block;
position:relative; }

#menu ul li:hover a {
background-color: #006699; }

#menu ul li ul li a:hover {
color: #0B5A7D;
font-weight: bold;
background-color: #89b4ca; }

#menu ul li ul li a {
clear: left;
line-break: strict;
background-color: #006699;
padding: 5px;
font-size: 12px; }

.menu ul li {
display: inline-block;
position: relative;
border-left: solid 1px #006699; }

#menu ul li ul li {
display: block;
float: none;
clear: left;
width: 200px;
border: none;
background-color: #006699; }

.menu li ul {
position: absolute; }

.menu li:not(:hover) ul {
display: none; }
Katy
  • 199
  • 2
  • 4
  • 12
  • This might be better on http://wordpress.stackexchange.com/ – Ahmad Oct 20 '12 at 01:32
  • Hi, thanks for the advice. But do you really think that I should ask my questions there? It's more a CSS and Android problem because I don't use the wordpress widget anymore because it didn't work! The menu is pure CSS and PHP/HTML. – Katy Oct 20 '12 at 01:36
  • hmm, yes in that case you're right, sorry. – Ahmad Oct 20 '12 at 01:39
  • To those who voted my question down: Why do you vote my question down? Should I explain something more precisely or provide some code? I have never before developed anything for android, feel a little overwhelmed with this. Please let me know if my question is stupid and how I can improve it! Thanks. – Katy Oct 20 '12 at 01:52
  • 3
    seeing some code would definitely encourage people to help, there is no way to debug your problem without it. Also, people here expect to see what you've tried. – Luca Oct 20 '12 at 02:10
  • @Luca: Thank you! I will have access to the code on Monday again, I will update my question asap! – Katy Oct 20 '12 at 21:45
  • Hi guys, I added my code to my question. Please let me know if you need any additional information. I appreciate your help a lot! – Katy Oct 22 '12 at 15:14

1 Answers1

0

Here is a little script I created to convert normal menus to a select dropdown and then I believe I used media queries to switch out menus. Going to be making this a more flexible plugin soon probably.

http://imstillreallybored.com/2012/jquery-snippet-for-mobile-menu/

Josh Bedo
  • 3,410
  • 3
  • 21
  • 33
  • thanks for the script! I cannot try it today because my server is down unfortunately but I will do that in the next few days. – Katy Oct 22 '12 at 21:04
  • Cool, I'm actually making a plugin right now extending the script. Taking suggestions for the flexibility ;) – Josh Bedo Oct 23 '12 at 05:07
  • Started plugin here not complete so code on my blog but stay up to date with this as well :) https://github.com/joshbedo/Menify – Josh Bedo Oct 23 '12 at 13:11
  • thanks :) my server is online again but I am going to have 2 weeks holidays from now on ... will be back in the mid of November and try this!! – Katy Oct 26 '12 at 17:26