Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make CSS dropdown menu on click to dropdown
    primarykey
    data
    text
    <p>How to make the following css dropdown menu only accept click to dropdown? For example, now when mouse hover "Please Select". The second layer appears. I want to change to when click "Please Select", the second layer appears. Also the click event should apply to second layer menu.</p> <p>This is a <a href="http://jsfiddle.net/donli/panzd/#base" rel="nofollow">Fiddle</a></p> <p>I'm using jquery but don't know how to do this. </p> <p>The html codes</p> <pre><code> &lt;ul class="dropdown"&gt; &lt;li&gt;&lt;a href="#"&gt;Please select&lt;/a&gt; &lt;ul class="sub_menu"&gt; &lt;li&gt; &lt;a href="#"&gt;Artificial Turf&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Indoor&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Outdoor&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#"&gt;Batting Cages&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Indoor&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Outdoor&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul​ </code></pre> <p>The CSS code</p> <pre><code>/* LEVEL ONE */ ul.dropdown { position: relative; } ul.dropdown li { font-weight: bold; float: left; zoom: 1; background: #ccc; } ul.dropdown a:hover { color: #000; } ul.dropdown a:active { color: #ffa500; } ul.dropdown li a { display: block; padding: 4px 8px; border-right: 1px solid #333; color: #222; } ul.dropdown li:last-child a { border-right: none; } /* Doesn't work in IE */ ul.dropdown li.hover, ul.dropdown li:hover { background: #F3D673; color: black; position: relative; } ul.dropdown li.hover a { color: black; } /* LEVEL TWO */ ul.dropdown ul { width: 220px; visibility: hidden; position: absolute; top: 100%; left: 0; } ul.dropdown ul li { font-weight: normal; background: #f6f6f6; color: #000; border-bottom: 1px solid #ccc; float: none; } /* IE 6 &amp; 7 Needs Inline Block */ ul.dropdown ul li a { border-right: none; width: 100%; display: inline-block; } /* LEVEL THREE */ ul.dropdown ul ul { left: 100%; top: 0; } ul.dropdown li:hover &gt; ul { visibility: visible; }​ </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload