Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Drop Down Sub Menu Not Working on Mobile

New Here ,
Jun 23, 2017 Jun 23, 2017

I have everything in place for my drop down sub-menu which works in testing on shrunken screen but will not work on my HTC One when I check it now we have gone live! I am guessing that the issue to hand is that once you have pressed the hamburger to expand the menu down it goes about half way down the screen with clickables and the last choice you get is the celebration drop down menu, click on this and the menu does drop down to the final choice being the 'Make Your Choice' as the very bottom item (which is the very bottom of my screen, now when you click on that (tap) instead of opening the further choices up it closes the choices down to top drop down menu i.e. celebration stationery option. I am guessing this is because the second drop down has no where to go as there is no screen left under the 'Make Your Choice'.

This is obviously not acceptable as it makes a large percentage of the site not available to mobile viewing. Does anybody have any suggestions for fixing this issue? There is still another page to go under Font Choices in the sub menu drop down.

In-case you want to check this out for yourself on your mobiles then please go to AD Design & Print. I would appreciate help with this as the site is now live with all pages passing WC3 validation.apart from Contact-us that has an 'error' in the embedding code supplied by Google for the map.

11.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 23, 2017 Jun 23, 2017

Try including the below script after the link to your Bootstrap js file at the foot of your page. That should stop the default toggle collapsing all open states.

<script>

$(document).ready(function(){

  $('.dropdown-submenu a').on("click", function(e){

    $(this).next('ul').toggle();

    e.stopPropagation();

    e.preventDefault();

  });

});

</script>

Translate
LEGEND ,
Jun 23, 2017 Jun 23, 2017

Measha06  wrote

I am guessing this is because the second drop down has no where to go as there is no screen left under the 'Make Your Choice'.

No, its not. It's because Bootstrap is toggling the 'open states' and closing all the open states.

I don't know how Bootstrap toggle works (and dont really want to) so you will have to wait for someone who does and can give you some advice, the submenu probably needs a bit of onclick javascript of its own to work correctly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2017 Jun 23, 2017

Thanks for input

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2017 Jun 23, 2017

Try including the below script after the link to your Bootstrap js file at the foot of your page. That should stop the default toggle collapsing all open states.

<script>

$(document).ready(function(){

  $('.dropdown-submenu a').on("click", function(e){

    $(this).next('ul').toggle();

    e.stopPropagation();

    e.preventDefault();

  });

});

</script>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2017 Jun 23, 2017

Sorry been out all day.

I have only put it on the index page to test and it seems to partially work. The Make your choice does drop down now but certainly on my phone it only goes as far as 'Accessorie Choices', the following three don't show at all, so neither will last when it is put there!

Any suggestions before I add that script to all 31 pages produced so far!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 24, 2017 Jun 24, 2017

Measha06  wrote

Sorry been out all day.

I have only put it on the index page to test and it seems to partially work. The Make your choice does drop down now but certainly on my phone it only goes as far as 'Accessorie Choices', the following three don't show at all, so neither will last when it is put there!

Any suggestions before I add that script to all 31 pages produced so far!

Do they not show even if you scroll down?

I think as was mentioned in the previous post in another thread submenus 2 or 3 deep don't work that well on mobile. You should really just have a top level link which links to that section of the website where your sublinks can reside or you need a different menu system for mobile where the sublinks slide in from the side, over the top of the main navigation, taking less real estate.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2017 Jun 24, 2017

No they only scroll as far as Accessories which is the third and there are 6 now will be 7 sections. I have not seen the mention of sub-menus only going 2-3.

I like the idea of sliding but in but would take deep investigation how to organise that!

Thanks again

Liz

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 25, 2017 Jun 25, 2017

Measha06  wrote

I like the idea of sliding but in but would take deep investigation how to organise that!

Example code below. If you can imagine it and you can code - you can do it. This example slides down from the top. With a little more work it could slide in from the side.

Personally I would remove that duff old one dimensional Bootstrap stuff and use something more suited, which is going to give your users a better and more organised experience.

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8" />

<title>Drop Menu</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>

</head>

<body>

<style>

body {

margin: 0;

}

/* zero out all padding/margin */

* {

box-sizing: border-box;

}

.outer-navigation-wrapper {

background-color: #B771E7;

}

/* main navigation wrapper */

.main-navigation-wrapper {

width: 80%;

margin: 0 auto;

font-family: helvetica, sans-serif;

}

@media (max-width: 960px) {

.main-navigation-wrapper {

width: 100%;

}

}

.main-navigation {

display: -webkit-box;

display: -ms-flexbox;

display: flex;

-webkit-box-pack: end;

-ms-flex-pack: end;

justify-content: flex-end;

margin: 0;

padding: 0;

font-size: 18px;

line-height: 28px;

}

@media screen and (max-width: 960px) {

.main-navigation {

display: none;

}

}

.main-navigation li {

margin: 0;

padding: 0;

list-style: none;

position: relative;

}

@media screen and (max-width: 960px) {

.main-navigation li {

position: static;

}

}

.main-navigation li i {

font-size: 16px;

margin: 0 0 0 5px;

padding: 0;

}

@media screen and (max-width: 960px) {

.main-navigation li {

width: 100%;

}

}

.main-navigation a {

text-decoration: none;

color: #fff;

display: block;

padding: 15px;

font-size: 14px;

}

@media screen and (max-width: 960px) {

.main-navigation a {

padding: 15px 25px;

}

}

.main-navigation a:hover {

color: #000;

}

/* drop menu */

.main-navigation .drop-menu {

position: absolute;

top: 3.2em;

left: 0;

background-color: #fff;

border: 1px solid #f2f2f2;

margin: 0;

padding: 0;

width: 250px;

box-shadow: 7px 5px 7px #ccc;

}

@media screen and (max-width: 960px) {

.main-navigation .drop-menu {

top: 0;

left: 0;

border: none;

margin: 0;

padding: 0;

width: 100%;

box-shadow: none;

height: 100%;

}

}

.drop-menu li {

border-bottom: 1px solid #f2f2f2;

}

.drop-menu a {

padding: 15px 15px;

color: #000;

}

@media screen and (max-width: 960px) {

.drop-menu a {

padding: 15px 25px;

color: #000;

}

}

.drop-menu a:hover {

background-color: #f2f2f2;

}

/* drop menu sub */

.main-navigation .drop-menu-sub ul {

background-color: #fff;

}

@media screen and (max-width: 960px) {

.main-navigation .drop-menu-sub ul {

position: absolute;

top: 0;

left: 0;

border: none;

margin: 0;

padding: 0;

width: 100%;

box-shadow: none;

height: 100%;

}

}

.drop-menu-sub ul {

margin: 0;

padding: 0;

}

.drop-menu-sub ul li {

border: 1px solid #f2f2f2;

}

/* mobile menu icon */

.mobile-menu-icon {

display: none;

}

@media screen and (max-width: 960px) {

.mobile-menu-icon {

display: block;

text-align: right;

color: #fff;

padding: 15px 40px;

font-size: 20px;

}

.main-navigation li {

width: 100%;

}

}

.drop-menu .list-header {

font-size: 20px;

padding: 20px 15px 20px 25px;

color: #B771E7;

display: none;

}

@media screen and (max-width: 960px) {

.drop-menu .list-header {

display: block;

}

}

.drop-menu .close-sub-menu {

background-color: #B771E7;

color: #fff;

text-align: right;

border-bottom: none;

padding: 15px;

display: none;

}

@media screen and (max-width: 960px) {

.drop-menu .close-sub-menu {

display: block;

}

}

</style>

<script>

$(document).ready(function(){

//hide drop menu and drop menu sub

$('.drop-menu, .drop-menu-sub ul').hide();

//show drop menu

$('.main-navigation li').css('cursor', 'pointer').click(function() {

$(this).find('.drop-menu').slideDown().end().siblings().find('ul').hide();

});

// show mobile menu icon at 960px window width

$('.mobile-menu-icon').css('cursor','pointer').click(function(){

$('.main-navigation').slideToggle();

});

//show drop menu sub

$('.drop-menu-sub').css('cursor', 'pointer').click(function() {

$(this).find('ul').slideToggle().end().siblings().find('ul').hide();

});

// close sub menu

$('.close-sub-menu').css('cursor','pointer').click(function(){

$(this).parent('ul').slideUp();

return false;

});

//drop menu slide up if window width more than 960px

$('.drop-menu').mouseleave(function(){

if ($(window).width() > 960) {

$('.drop-menu').slideUp();

}                            

});

//realign main-navigation and hide drop menu at 960px window width

$(window).resize(function(){

if ($(window).width() > 960) {

$('.main-navigation').css('display', 'flex');

$('.drop-menu').hide();

}

else if ($(window).width() < 960) {

$('.main-navigation').css('display', 'none');

}

});

});

</script>

<div class="outer-navigation-wrapper">

<nav class="main-navigation-wrapper">

<div class="mobile-menu-icon"><i class="fa fa-bars"></i></div>

<ul class="main-navigation">

<li><a href="#">Home</a></li>

<li><a href="#">Contact Us</a></li>

<li><a href="#">Corporate</a></li>

<li><a href="#">Embroidery</a></li>

<li><a href="#">Everything Web</a>

</li>

<li><a href="#">Self Publishing</a></li>

<li><a href="#">Celebration Stationary<i class="fa fa-caret-down" aria-hidden="true"></i></a>

<ul class="drop-menu">

<li class="close-sub-menu">Main Menu<i class="fa fa-caret-up" aria-hidden="true"></i></li>

<li class="list-header">Celebration Stationary</li>

<li><a href="#">Celebrations</a></li>

<li><a href="#">Wedding Stationary Items</a></li>

<li><a href="#">FAQ</a></li>

<li class="drop-menu-sub"><a href="#">Make Your Choices<i class="fa fa-caret-down" aria-hidden="true"></i></a>

<ul>

<li class="close-sub-menu">Main Menu<i class="fa fa-caret-up" aria-hidden="true"></i></li>

<li class="list-header">Make Your Choices</li>

<li><a href="#">Base Choices</a></li>

<li><a href="#">Card Choices</a></li>

<li><a href="#">Accessory Choices</a></li>

<li><a href="#">Weddding Invitation Wording</a></li>

<li><a href="#">Weddding Evening Invitation Wording</a></li>

<li><a href="#">Font Choices</a></li>

</ul>

<!-- end drop-menu -->

</li>

</ul>

<!-- end drop-menu -->

</ul>

<!--end main-navigation-->

</nav>

<!-- end main-navigation-wrapper -->

</div>

<!-- end outer-navigation-wrapper -->

</body>

</html>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 25, 2017 Jun 25, 2017

When my brood have gone to bed and I have peace I shall have a look later as I am very interested in this. Been drilling and plugging walls all day for my daughter who has moved from flat to house yesterday!  Bit shattered at the moment and need to absorb this. Many Thanks

Liz

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 25, 2017 Jun 25, 2017

Measha06  wrote

When my brood have gone to bed and I have peace I shall have a look later as I am very interested in this. Been drilling and plugging walls all day for my daughter who has moved from flat to house yesterday!  Bit shattered at the moment and need to absorb this. Many Thanks

Liz

If you can drill and plug walls then this should be a 'walk in the park' for you. I don't know the front end of a drill from the back end.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 25, 2017 Jun 25, 2017

Ah well we'd make a good team then. I can understand drilling and plugging and construction etc but get a bit bogged down in the code! I think I said before my original training in coding was in Basic then some in Fortran (not sure that's how you spell that) but as I was reminded the other day by my daughter's partner that wasn't yesterday!! We decided it was 40 ish years ago! 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 25, 2017 Jun 25, 2017

I noticed you have used 960 as max width do you have a reasoning behind this as I was thinking mobiles were below 761?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 25, 2017 Jun 25, 2017

Measha06  wrote

I noticed you have used 960 as max width do you have a reasoning behind this as I was thinking mobiles were below 761?

I tend to look at when the desktop menu starts to break down and that happens in fact just before 960px. Since we dont really know who is viewing on what device and at what window width I think its always best to start re-arranging elements when they begin to fall apart, rather than at set media breaks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2017 Jun 26, 2017

Thanks for the explanation. So you would only go for two sections so to speak, Desktop and below 960? Do you do anything separate for print?

Liz

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2017 Jun 26, 2017

Measha06  wrote

Thanks for the explanation. So you would only go for two sections so to speak, Desktop and below 960?

For the navigation, yes. Once it gets to 960px then from then on down no need to change the structure as it will fit any width device.

Measha06  wrote

Do you do anything separate for print?

No, I never get involved in producing a css file specifically for print. I think it used to be popular but not so much now, I believe. Others may have differing views.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2017 Jun 26, 2017

I have been playing with that Nav bar and its brilliant but.................................. I seem to have a problem!!! Firstly I've uploaded the file as a one page document to the following address to play Test. Now when I use Google or IE or Edge on my laptop and shrink screen to replicate mobile it is brilliant with menu overlays etc and I think works wonderfully, then I went to look at it on my mobile and all I can see is a really minaturised version of desktop so tiny you cant read writing and it just doesn't go to Hamburger sign or anything. I've tried on both my HTC and my husbands iPhone so is it because the css is trying to overide from my site?

Moving forwards to use the nav you have kindly sent me. Would I split the style section out into my CSS file and would I add the other lines into each and every page? Also how much coding would I remove from each page to take out present nav bar without braking the pages?

Sorry so many questions!

Liz

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2017 Jun 26, 2017

Measha06  wrote

I have been playing with that Nav bar and its brilliant but.................................. I seem to have a problem!!! Firstly I've uploaded the file as a one page document to the following address to play Test. Now when I use Google or IE or Edge on my laptop and shrink screen to replicate mobile it is brilliant with menu overlays etc and I think works wonderfully, then I went to look at it on my mobile and all I can see is a really minaturised version of desktop so tiny you cant read writing and it just doesn't go to Hamburger sign or anything. I've tried on both my HTC and my husbands iPhone so is it because the css is trying to overide from my site?

Add the meta viewport tag to the <head></head> section of the page:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2017 Jun 26, 2017

Measha06  wrote

Moving forwards to use the nav you have kindly sent me. Would I split the style section out into my CSS file and would I add the other lines into each and every page? Also how much coding would I remove from each page to take out present nav bar without braking the pages?

Sorry so many questions!

Liz

Just remove the present html code (see below) and replace it with the new html code:

You can then copy the css for the navigation and put it in its own file - main-navigation.css  and link it to the page:

<link href="css/main-navigation.css" rel="stylesheet" type="text/css">

Then copy the code between the <script></script> tags and put that in its own file - main-navigation.js and link it to the page:

<script src="js/main-navigation.js"></script>

PRESENT HTML CODE:

<nav class="navbar navbar-default navbar-fixed-top"> 

  <div class="container">  

  <!-- Brand and toggle get grouped for better mobile display --> 

  <div class="navbar-header"> 

  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#topFixedNavbar1" aria-expanded="false"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button> 

  </div> 

  <!-- Collect the nav links, forms, and other content for toggling --> 

  <div class="collapse navbar-collapse" id="topFixedNavbar1"> 

  <ul class="nav navbar-nav navbar-right"> 

  <li><a href="index.html">Home</a></li> 

  <li><a href="contact-us.html">Contact Us</a></li> 

  <li><a href="business-stationery.html">Corporate</a></li> 

  <li><a href="embroidery.html">Embroidery</a></li> 

  <li><a href="everything-web.html">Everything Web</a></li> 

  <li><a href="self-publishing.html">Self-Publishing</a></li> 

  <li class="dropdown">  

  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Celebration Stationery <span class="caret"></span></a> 

  <ul class="dropdown-menu"> 

  <li><a href="celebrations.html">Celebrations</a></li> 

  <li><a href="wed-stationery-items.html">Wedding Stationery Items</a></li> 

  <li role="separator" class="divider"></li> 

  <li><a href="faq.html">FAQ</a></li> 

  <li role="separator" class="divider"></li> 

  <li class="dropdown-submenu pull-left"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Make Your Choices</a> 

  <ul class="dropdown-menu"> 

  <li><a href="cardbases.html">Base Choices</a></li> 

  <li><a href="cardchoices.html">Card Choices</a></li> 

  <li><a href="accessoriechoices.html">Accessorie Choices</a></li> 

  <li><a href="weddinginvitationwording.html">Wedding Invitation Wording</a></li>

  <li><a href="eveninginvitationwording.html">Wedding Evening Invitation Wording</a></li> 

  <li><a href="#">Font Choices</a></li> 

  </ul> 

  </li> 

  </ul> 

  </li> 

  </ul> 

  </div> 

  <!-- /.navbar-collapse -->  

  </div> 

  <!-- /.container-fluid -->  

</nav>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2017 Jun 26, 2017

I was working in the right direction but hadn't thought of doing two new files linked!!! I just didnt want to work on assumption on 31+ pages and then get it wrong and have to redo 31+ pages.

Many Many thanks for your input. I shall work on this tomorrow. I have tried the extra line and all is cool on my mobile.

Liz

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2017 Jun 27, 2017

As promised I have today changed the coding on all the pages and uploaded. The mobile version appears to be working well when previewing it on shrunken desktop screens yet to go through it on my mobile. However there seems to be a couple of issues on desktop.

  1. If you are viewing on a widescreen nav bar stretched and goes over the edge of the page so the drop down goes over the background - not sure I like that look!
  2. In desktop view the drop down menu goes behind the wording and carousels etc so choices cannot be clicked on as you go down the list.

Can you please have a look and advise.

Liz

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 27, 2017 Jun 27, 2017

Thats just the way the design is. Your page is quite narrow 1000px wide and you have  no padding around the text to allow the content to 'breathe' which doesnt help matters. So naturally a drop-menu will stick outside of the narrow container if the drop-menu is associated with the last link. All these aspects need careful planning at the outset of a project.

To negate 1 and 2 you would need to really set the width of the navigation to a max-width: 1000px, add position: relative; and set a z-index: 1000; on the 'main-naviagtion-wrapper' :

/* main navigation wrapper */

.main-navigation-wrapper {

width: 80%;

margin: 0 auto;

font-family: helvetica, sans-serif;

max-width: 1100px;

position: relative;

z-index: 1000;

}

and then centre the links by updating the 'main-navigation' css (see below) This will then allow for the drop-menu to sit within the content area.

.main-navigation {

display: -webkit-box;

display: -ms-flexbox;

display: flex;

-webkit-box-pack: center;

-ms-flex-pack: center;

justify-content: center;

margin: 0;

padding: 0;

font-size: 18px;

line-height: 28px;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2017 Jun 27, 2017

Thanks again I'll try the addition of this. The page width is the default Dreamweaver width, so I followed what it suggested.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2017 Jun 27, 2017

That is much better many thanks I am just fixing the positioning of nav bar now as it is naturally showing with a band above it. Ive put a margin in of -10px which removes the gap but is this the best way to do it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 27, 2017 Jun 27, 2017

Im not at my computer right  now but you should not have to give the navigation a negative margin to get it to sit at the top of the page. If there is a gap then its something else that is causing the gap. I will have a look later.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2017 Jun 27, 2017

I will remove my negative margin so you see fairly!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines