CSS Drop down menu on mobile. how to get around :hover - javascript

I've had a search and I couldn't find anything & also it's my first time using the site so hope it hasn't been asked.
I've run into a situation. I'm by no means an experienced website maker. I'm learning as I go. I have a CSS drop down menu that works fine on desktop browsers. When I get into the realm of mobile I encounter a problem, namely that :hoverdoesn't work (obviously).
I found this : http://osvaldas.info/drop-down-navigation-responsive-and-touch-friendly but I can't get the ruddy thing to work.
The page in question I'm applying it to is here : http://www.inkslinger.co.uk/calibre/index.html I really can't work this out and its driving me absolutely batty. Any help would be really appreciated.

I had the same problem and found an easy workaround which I have used here
hover example
The Post Natal and Ante Natal options, when hovered over, trigger the drop down, but you may notice that they are NOT links themselves. In my original model they were links, but when I realised this would not work on touch devices, I simply made them into triggers for the drop down boxes, and put the links inside the boxes too. So for you, your 'What we do' link, would not be a link, just a trigger for the dropdown menu, and then in the menu you can have your link to the 'what we do' info.
It is also worth remembering that certain touch devices, such as some iPads, do not like hover states at all, if you find that the hover state won't trigger your dropdown menu, then add 'onclick="return true"' to the list item in question. This will usually make the hover state work like a click.
Hope this helps, what I've written represents about 3 days of poring over my library of reference books.

We had this problem and changed the hover to clicks.

Instead of using hover, which is of course impossible on touch devices, using :active would likely be a good start. Selection something is still possible on touch devices, bind the menu to the active state of a toggle and you're done.

You will have to switch from hover to click event for this case. There's no workaround for that.
You should definitely consider changing your design to have a hamburger styled menu which opens from left for touch devices.
See this demo from the link that you posted. It changes to a different menu style when you open it in mobile device.
http://osvaldas.info/examples/drop-down-navigation-touch-friendly-and-responsive/
Also if you want to have your top link as a direct link to other page; you can have two separate clicks on the top button for that. First click will open the menu and after the menu is opened you can assign the direct link to it as done in the above demo.

Put this line of code inside your head tag like this:
<head>
<script>document.addEventListener("touchstart", function(){}, true);</script>
</head>
Create for your hover element an active class like this:
element:hover, element:active { Your CSS }
Voila.

Related

Need JS help- collapsing a toggled down element when another is selected

Need help with the "our team" section halfway down this page: http://dev.doubleaevents.com/
When you click an image it opens to reveal more information. I'd like to be able to click another image and have the previously opened image collapse, so that a user can't open more than one image at a time.
Would also like to know if making them slide out to the right (instead of down) would be a simple fix?
I'm a js novice so any explanations are appreciated. Here's the js file for quick reference: http://dev.doubleaevents.com/wp-content/plugins/portfolio-gallery/assets/js/view-toggle-up-down.js
Try adding this:
jQuery('.portelement').each(function(){
if(jQuery(this).hasClass('large')){
jQuery(this).removeClass('large');
jQuery(this).animate({
height:240
},300);
}
});
before:
jQuery(this).parents('.portelement').addClass('large');
In your javascript code.
When you click an item you basically want to search for elements that are already open. Then from there remove the 'large' class name and close that element. From there you continue on to opening the selected element. Thats what this code does.
As far as your other question, it shouldn't be too difficult, just mess around with the animate method and css. But maybe look into the isotope documentation. There may be an option for that.

custom css select menu gets cut off at the bottom in chrome

Here's a link to my page:
http://2plygraphics.com/im-here/
I have custom select menus and form elements using the :before and :after pseudo tags. There is also a lot of javascript making things hide/show etc.
If you view the page in Chrome you will notice that on the first click of any select menu in the page, the contents of the menu get cut off at the bottom. Once you have clicked once, all menus work as designed. It also appears to be a compounding issue, in that, if a menu has 11 items it is cut off more than one with 2 items. Once the page is refreshed the issue happens again...
I have tried changing or removing line heights, padding, margins, the overflow method etc. Starting to lose perspective...any help would be appreciated.
OK, here is an image of it in action:
http://i59.tinypic.com/33ljm35.png
I have tested this in windows 7 using Chrome Version 33.0.1750.154 m
Update
Does anyone have any suggestions for working around this? I'm thinking maybe faking a click on one of the select menus to get it to "activate" after the page has loaded...
I had the same problem in Chrome/Win8.1 and i could solve that by removing the font-family setting on the select-element in my css. Without that everything was working like it should.

jQuery Accordion Menu Items Remain Open Until Clicked

I have made a jQuery accordion menu but it doesn't seem to be acting in the default manner. Basically, when I click on a menu item the item opens as expected. However, when I click on a different menu item it also opens as expected but the first menu item remains open. The jQuery documentation states:
"An accordion doesn't allow more than one content panel to be open at the same time, and it takes a lot of effort to do that."
I promise it took very little effort to break this default functionality ;). Anyway, I have posted my JS, HTML and CSS on JSFiddle and am hoping someone can point me in the right direction. Other than opening and closing it works fine, even though it doesn't appear to on JSFiddle. Here's the link: JSFiddle Post
Thanks in advance.
Ken
Can You Organize your output page in the way that I at least can see the menu clearly. Its difficult to access the them in your html

Hover over something for information to appear in another

I have been trying to find ways to to hover over something so that more information will appear in a different section. I have been looking at similar questions that were posted but I am still not sure how to do it.
I want "Recently on Sale" to show up first, then as I hover over the others, more information will appear for them respectively. Here is the link to what I have been working on: http://jsfiddle.net/saikirakiva/jVaLd/
I have been using just css, is javascript more suitable for what I am trying to do?
Thank you!
JavaScript is useful because it allows you to delay hiding the second element when the mouse moves away from the first element. This feature is especially important in nested drop down menus, because users frequently leave a menu item for a short time while navigating to its submenu.
you can do it like this: http://jsfiddle.net/mnbayazit/Vhg6p/9/

How to expand on mouse click

http://findaccountingsoftware.com/directory/gba-systems/fams-fixed-assets-management-system/
this site contain a tab container. On Applications tab clicking on + sign it goes to expand, I want to know this process name. How to do it?. There is a strange thing occur clicking on + sign expand automatically scroll move and focus on text. What this process name is. How to do that?
This effect is called an 'accordion' menu. jQuery UI has a great one which you can use and also has some great documentation explaining how to use it :)
http://jqueryui.com/demos/accordion/
Beautiful full customization accordion in Bootstrap.
Please refer the following documentation.
https://getbootstrap.com/docs/5.0/components/accordion/

Categories