Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hey guys I've been trying to create a mobile friendly menu. In desktop mode it works fine, but on a mobile phone the links are somehow replaced by # and thus not working. I suppose the issue is with the script that is associated with the menu, but I can't figure out the problem. Could someone help me out?

 

thnx!

 

html:

<a href="#" class="top-menu-button"></a>

<nav id="top-menu" class="fake">
     <ul id="menu-main-menu" class="menu">
          <li id='main-menu-5078'><span class="menu-item-wrap no_icon"><a  href="link"  style=""><span class="link-text">Home</span></a></span><div class='under'></div></li>
                
          <li id='main-menu-5079'><span class="menu-item-wrap no_icon"><a href="http://url.com"  style=""><span class="link-text">Blog page</span></a></span><div class='under'></div></li>

          <li class="current-menu-item" id='main-menu-5092'><span class="menu-item-wrap no_icon"><a  href="http://www.url.com"  style=""><span class="link-text">Contact</span></a></span><div class='under'></div></li>
     </ul>
</nav>

javascript:

<script type="text/javascript">

    jQuery(document).ready(function () {

        var menu_speed = 'normal';
        var animation_effect = 'fade_in';

		jQuery("nav#top-menu > ul > li > ul").hide();

        var windowWidth = jQuery(window).width();

        jQuery(window).resize(function() {
            //jQuery("nav#top-menu > ul > li > ul").hide();
            windowWidth = jQuery(window).width();
            //alert(windowWidth);
        }).resize();


            if(windowWidth < 767)
            {
                jQuery("nav#top-menu > ul > li").click(function () {
                    jQuery('a:first', this).attr("href", "#");
                    jQuery('ul', this).show();
                });

            }
            else
            {
                jQuery("nav#top-menu > ul > li").hover(function () {

                    if (animation_effect == 'fade_in')
                        jQuery('ul', this).stop(true, true).fadeIn(menu_speed);

                    if (animation_effect == 'slide_down')
                        jQuery('ul', this).stop(true, true).slideDown(menu_speed);


                }, function () {

                    if (animation_effect == 'fade_in')
                        jQuery('ul', this).stop(true, true).fadeOut(menu_speed);

                    if (animation_effect == 'slide_down')
                        jQuery('ul', this).stop(true, true).slideUp(menu_speed);

                });
            }


        jQuery('nav#top-menu > ul > li').mouseleave(function() {
            jQuery("nav#top-menu > ul > li > ul").hide();
        });
        
    });


</script>

Edited by PietPuk

  • Author

I suppose it is due to this part, but I'm confused about how to fix it...

 

if(windowWidth < 767)
            {
                jQuery("nav#top-menu > ul > li").click(function () {
                    jQuery('a:first', this).attr("href", "#");
                    jQuery('ul', this).show();
                });

            }
            else

How about CSS3 like on my site:

 

<div id="nav">
	<ul id="navbar">
		<li><a href="http://formworkinlondon.co.uk/index.php">home</a></li>
    	<li><a href="http://formworkinlondon.co.uk/about-us.php">about us</a></li>
		<li><a href="http://formworkinlondon.co.uk/portfolio.php">portfolio</a>
    		<ul class="sub1">
        		<li><a href="http://formworkinlondon.co.uk/structures.php">concrete structures</a></li>
				<li><a href="http://concretestairslondon.co.uk/portfolio.php" target="_blank">concrete stairs</a></li>
			</ul>
			<li><a href="http://formworkinlondon.co.uk/contact.php">contact us</a></li>
			<li><a href="http://formworkinlondon.co.uk/faq.php">faq\'s</a></li>
		</li>	
	</ul>
/*Navbar Formatting*/
/*First menu; home, about us, portfolio*/
#navbar {
width: 100%;	
z-index: 8000;
position: absolute;
}

ul#navbar li {
display: inline;
display: block;
position: relative;
float: left;
width: 20%;
text-align: center;
background-color: #F90;
border: 20% solid #CCC;
}

ul#navbar li a:hover {
color: #CCC;	
}

ul#navbar li a {
display: block;
color: #999;	
font-size: 2em;
}
/*First Menu*/

/*Sub Menu Portfolio*/
ul#navbar ul {
display: none;
position: relative;	
}

ul#navbar li:hover > ul {
display: block;	
}

ul#navbar li ul li {
width: 100%;
background-color: #FC9;
}
/*Sub Menu*/

/*Sub Sub Menu; Concrete Structures, Concrete Stairs*/
ul#navbar li:hover ul {
display: block;	
}

ul#navbar li ul li {
width: 100%;
}

ul#navbar li ul li a{
font-size: 1.5em;	
}
/*Sub Sub Menu*/
/*Navbar Formatting*/

  • Author

Thnx! Actually the menu is formatted with css3 already and it looks quite nice! However I've tried to integrate some jquery to have a sliding effect, but it's that part that seems to break the menu ;)

Edited by PietPuk

Ah sorry, I think a lot of JQuery's effects are not available on mobile devices yet.

 

I started to really get into a couple of JQuery tutorials on CodeAcademy but stopped myself when I learned unavailable to mobiles.

 

jQuery does work on mobiles, just not fancy hover effects.

 

They even have a mobile framework (http://jquerymobile.com/).

jQuery does work on mobiles, just not fancy hover effects.

 

They even have a mobile framework (http://jquerymobile.com/).

 

Thanks for that link Jack, hope I'm not coming across rude, it's probably my mistake but:

 

Doesn't look very good. I just quickly played with that link with a button with a slide down transition, then went to test; doesn't work.

 

Looks like there are hardly any effects compared to real JQuery.

Thanks for that link Jack, hope I'm not coming across rude, it's probably my mistake but:

 

Doesn't look very good. I just quickly played with that link with a button with a slide down transition, then went to test; doesn't work.

 

Looks like there are hardly any effects compared to real JQuery.

 

jQuery mobile is almost purely for creating mobile websites. The standard jQuery framework works on mobiles as well, however some plugins and UI are not suited to mobile.

 

We have built a fair few mobile sites using jQuery mobile, it works really well.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.