logo
down
shadow

Open Dropdown with hover and close menu when click a link


Open Dropdown with hover and close menu when click a link

By : lamin s kinteh
Date : November 21 2020, 07:01 PM


Share : facebook icon twitter icon
How to get dropdown menu to open/close on click rather than hover?

How to get dropdown menu to open/close on click rather than hover?


By : Paul Cline
Date : March 29 2020, 07:55 AM
should help you out I am very new to javascript and ajax/jquery and have been working on trying to get a script to open and close the drop menu on click rather that hover.
code :
 $(function() {
     $("#lang-selector li:first").click(function(){
         $('ul:first',this).toggle();
     })
 });
How to close hover dropdown menu on outside click?

How to close hover dropdown menu on outside click?


By : Tube Oid
Date : March 29 2020, 07:55 AM
hope this fix your issue I reviewed your code and posted an example of what you want. This is a more simple way of achieving your goal. This is an example you will have to apply it to your code. This is a pure css and html solution using checkboxes and labels. Below is detailed information on how it works. Hope it helps. Enjoy.
code :
<html>
<head>
<title></title>
<style>
.buttoncomtainer1{ /*A wrapper for your hover dropdown List*/
width:100px;
height:2em;
float:left;
position:absolute;  
z-index:20;
}
.mycheckButton{ /*Your Label acts as a Button Triggering the checkbox*/
width:100px;
height:2em;
float:left;
display:block;
background-color:blue;
text-align:center;
color:#ffffff;
position:fixed; 
z-index:20;
}
.mycheckDrop{ /*Your Dropdown*/
width:100px;
float:left;
display:none;
padding:1%;
background-color:green;
position:fixed; 
z-index:20;
margin-top:2em;
}

.gone{ /*Make your checkbox disappear*/
border:0px;
outline:none;
line-height:0;
display:none;
margin:0px;
padding:0px;
width:0px;
height:0px;
}
.blackout{ /*This Div covers the page with the labelBlackout Label in it. nothing can be clicked unless The Label inside clicked first triggering the checkbox. */
width:100%;
height:100%;
float:left;
position:fixed;
z-index:15; 
background-color:transparent; /*    You can add a background color like this. background-color:black; opacity:0.7;*/
display:none;
}  
.labelBlackout{ /*the Label inside the blackout div that covers the page*/
width:100%;
height:100%;
float:left; 
}  
.lnkCon{    /*  Container that holds your dropdown links.*/
width:100%;
height:2em;
float:left; 
margin-top:5px;
}
input[type=checkbox].gone:checked ~ div.blackout{display:block;}  
input[type=checkbox].gone:checked ~ label.mycheckDrop{display:block;}    
.buttoncomtainer1:hover > .mycheckDrop{display:block;}


</style>
</head>
<body>
<div class="buttoncomtainer1">
<input class="gone" id="myCheck" type="checkbox" >
<div class="blackout" ><label class="labelBlackout" for="myCheck"></label></div>
<label class="mycheckButton" for="myCheck">DropDown</label>
<label class="mycheckDrop" for="myCheck">
<span class="lnkCon"><a href="#">Button 1</a></span>
<span class="lnkCon"><a href="#">Button 2</a></span>
<span class="lnkCon"><a href="#">button 3</a></span>
</label></div>
</body>
</html>
drop down menu open but when mouse hover on dropdown item ,dropdown menu close

drop down menu open but when mouse hover on dropdown item ,dropdown menu close


By : K Lin
Date : March 29 2020, 07:55 AM
how to make this dropdown-menu open and close on hover

how to make this dropdown-menu open and close on hover


By : user1501431
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I want to open this dropdown menu on hovering mouse on it. I have tried to open this dropdown-menu with onclick command but I was not fully succeeded in that, so I decided to make dropdown-menu on hovering. , CSS:
code :
.menuBtn
{
    background-color: #ccc;
    color: #fff;
    padding: 10px 50px;
    font-size: 16px;
    border: none;
}
.custom-menu 
{
    position: relative;
    display: inline-block;
}
.custom-menu-item
{
    display: none;
    position: absolute;
    background-color: #f1f1f1;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
}
.custom-menu:hover .custom-menu-item 
{
    display: block;
}
.custom-menu-item a
{
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}           
.custom-menu-item a:hover
{
    background-color: #e7e7e7;
}
.custom-menu:hover .menuBtn 
{
    background-color: #aaa;
}
<div class="custom-menu">
            <button class="menuBtn">Menu</button>
            <div class="custom-menu-item">
                <a href="http://blog.fossasia.org" target="_blank">
                    <span class="custom-icon"><img src="{{ url_for('static', filename='blog.png') }}">
                    </span>
                    <span class="custom-title">Blogs</span></a>
                <hr style="margin-bottom: 10px; margin-top: 10px;">
                <a href="https://susper.com/" target="_blank">
                    <span class="custom-icon"><img src="{{ url_for('static', filename='susper.png') }}">
                    </span>
                    <span class="custom-title">Susper</span></a>
                <a href="https://chat.susi.ai/" target="_blank">
                    <span class="custom-icon"><img src="{{ url_for('static', filename='susi.png') }}">
                    </span>
                    <span class="custom-title">Susi</span></a>
                <a href="https://loklak.org/" target="_blank">
                    <span class="custom-icon"><img src="{{ url_for('static', filename='loklak.png') }}">
                    </span>
                    <span class="custom-title">loklak</span></a>
                <a href="https://phimp.me/" target="_blank">
                    <span class="custom-icon"><img src="{{ url_for('static', filename='phimp.png') }}">
                    </span>
                    <span class="custom-title">Phimp.me</span></a>
                <a href="https://pslab.fossasia.org" target="_blank">
                    <span class="custom-icon"><img src="{{ url_for('static', filename='Pslab.png') }}">
                    </span>
                    <span class="custom-title">PS Lab</span></a>
                <hr style="margin: 10px">
            <div>
                <span>&nbsp;&nbsp;&nbsp;&nbsp;More on</span><a href="https://labs.fossasia.org/" target="_blank">labs.fossasia.org</a>
            </div>
        </div>
    </div>
How to make this css based menu open and close on click instead of open on hover and close on mouseout?

How to make this css based menu open and close on click instead of open on hover and close on mouseout?


By : Josafá Oliveira de L
Date : March 29 2020, 07:55 AM
Any of those help :hover is a css class that you can use to change the appearance of things on... hover.
On order to "Click and do stuff" (even if it's basically changing the state/appearance of something, similar to that hover) use Javascript. So you'd need to add javascript and possibly jquery.
Related Posts Related Posts :
  • clickable div with img in it?
  • CSS multiple background
  • How to vertically align images in <td>
  • Design Web Templates
  • CSS DIV not expanding when more text is added
  • Are you familiar with <ins> tag in html?
  • HTML - decrease page size
  • WYSIWYG browser editor that generates *good* HTML?
  • Absolute positioning in IE6, using left: 0; and right: 0; simultaneously
  • How can I find out why a website looks different when I upload it to IIS?
  • Flash movies in inactive browser tabs pause or don't execute in real time
  • How to send HTML email using linux command line
  • Location of code when sending HTML Email
  • CSS challenge: Two background images, centered column with fixed with, min-height 100%
  • What about WebSafe colors
  • Justified navigation buttons
  • VBA - Number of Google News Search Results
  • IE8 opacity activex problem
  • Type attribute for text_field
  • How can I make my users automatically download the font I use for my website if they don't have it?
  • How to override css in material UI?
  • Multi-Page invoice printing on one page
  • when we mouse over a disabled button in FireFox,The title can't display
  • Div on top of Div using z-index
  • CSS : Style the span within div element
  • Raphael js text positioning: centering text in a circle
  • css overlapping content wanted
  • Setting height of div equal to containing div
  • Send HTML mail using Android intent
  • Underline ie6-bug. Inline element in <a> tag
  • Add color to selected <li> item / override <ul> style
  • How to change the strike-out / line-through thickness in CSS?
  • Why don't the images fully display when I convert HTML to PDF with Perl's HTML::HTMLDoc?
  • HTML overlay height to cover entire visible page
  • Anchor tags and target behaviour? - HTML
  • Does specifying image size in CSS allow the browser to do layout before download is complete?
  • How to make space between <p> elements
  • Need help making row of buttons consistent
  • onclick event in dropdown
  • How to retrieve the value passed in POST method?
  • How do I create breadcrumbs like in this Apple site?
  • Buttons size not equal in IE and Firefox
  • Need row to fill remaining space
  • IE6 the last three characters in a div are being repeated else where in the page? really weird
  • Website column width
  • I want to open html page as popup window in my html page when i press button
  • CSS Issue in Firefox/IE
  • Changing button text on hover
  • Reducing load time, or making the user think the load time is less
  • Is it good to put a &nbsp; inside an empty <td>?
  • Error while validating HTML "document type does not allow element "li" here; missing one of "ul"
  • How do I get HTML Tidy to not put newline before closing tags?
  • Creating a horizontal fluid layout in css that works like a table
  • clear view of box model
  • HTML+CSS: combining <UL>/<OL> and faux-tabular format
  • target="new" is not opening new tab or window of my browser in OpenSocial app
  • Where can I get this HTML editor
  • How to fix element not allowed as child?
  • How to embed PDF in a web page using Acrobat Reader instead of Acrobat
  • best method of making a tweet-this button?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk