473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How do you make submenu appear on hover?

20
hello,

I have this problem on making a sub-menu in my navigation bar. it seems to be overlapped. how can I prevent this? I can't work out how to make the sub-menu open when you hover on the main word.

I have use the display:none thingy, but still, it doesn't seems to work.

Expand|Select|Wrap|Line Numbers
  1. <div id="nav">
  2.     <ul>
  3.         <li><a href="admin.php">HOME</a></li><br>
  4.         <li><a href="#">USER</a><br>
  5.             <ul id="submenu"> 
  6.                  <li><a href="new.php"> Add New User</li>
  7.                  <li><a href="#"> Choose User</li>
  8.             </ul></li>
  9.  
  10.         <li><a href="#">Pengesah</a></li><br>
  11.         <li><a href="#">Penyedia</a></li><br>
  12.         <li><a href="#">UPDATE</a></li><br>
  13.         <li><a href="logout.php">LOGOUT</a></li>
  14.     </ul>
  15. </div>

this is the css,
Expand|Select|Wrap|Line Numbers
  1. div#nav{
  2.     text-align: center;
  3.     list-style: none;
  4.     font-size: 13px;
  5.     margin-bottom: none;
  6.     float: left;
  7.     padding-top: 5px;
  8. }
  9.  
  10. div#nav a {
  11.     text-decoration: none;
  12.     color: #000000;
  13.     display: block;
  14.     padding: 7px;
  15. }
  16.  
  17. div#nav ul {     
  18.     list-style-type: none;     
  19.     padding-left: 0;     
  20.     margin-left: 10px;
  21.     background:-o-linear-gradient(bottom, #0069d3 5%, #007fff 100%);    
  22.     background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #0069d3), color-stop(1, #007fff) );
  23.     background:-moz-linear-gradient( center top, #0069d3 5%, #007fff 100% );
  24.     filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#0069d3", endColorstr="#007fff");    
  25.     background: -o-linear-gradient(top,#0069d3,007fff);
  26.     background-color:#0069d3;
  27.     width: 140px;
  28.     height: 840px;
  29.     border-left: 2px solid #000000;
  30.     border-right: 2px solid #000000;
  31.     position: relative;
  32.     display: inline-table;
  33. }
  34.  
  35. div#nav li {     
  36.     text-decoration: none;       
  37.     display: block;     
  38. }
  39.  
  40. div#nav li{         
  41.     display: block;  
  42.     background-color: #ce90dd;
  43.     border: 2px dashed #000000;     
  44.     border-left: 5px solid #000000;  
  45.     border-right: 5px solid #000000;   
  46.     border-bottom: 2px dashed #000000;
  47.     margin: 10px 0 10px 0;
  48.     margin-bottom: none;
  49.     width: 100px;
  50.     float: left;
  51.     padding: 15px;
  52.     height: 30; //tinggi block//
  53. }
  54.  
  55. div#nav li a:hover {
  56.     color: #FFFFFF;
  57.     background-color: #35af3b;
  58. }
  59.  
  60. #submenu ul ul {
  61.     display: none;
  62.     }
  63.  
  64. #submenu ul li: hover > ul {
  65.     display: block;
  66.     }
  67.  
  68. #submenu ul li {
  69.     background:##4b545f;
  70.     background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
  71.     background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);
  72.     background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%);
  73.     }
  74.  
  75. #submenu ul li:hover a{
  76.     color:#fff;
  77.     }
  78.  
  79. #submenu ul li a{
  80.     display:block; 
  81.     padding: 25px 40px;
  82.     color:#757575; 
  83.     text-decoration: none;
  84.     }
Jan 15 '14 #1

✓ answered by Exequiel

try this, ,
css .....
Expand|Select|Wrap|Line Numbers
  1. div#nav{
  2.     text-align: center;
  3.     list-style: none;
  4.     font-size: 13px;
  5.     margin-bottom: none;
  6.     float: left;
  7.     padding-top: 5px;
  8. }
  9.  
  10. div#nav a {
  11.     text-decoration: none;
  12.     color: #000000;
  13.     display: block;
  14.     padding: 7px;
  15. }
  16.  
  17.  ul#submenu,
  18. div#nav ul#myul {     
  19.     list-style-type: none;     
  20.     padding-left: 0;     
  21.     margin-left: 10px;
  22.     background:-o-linear-gradient(bottom, #0069d3 5%, #007fff 100%);    
  23.     background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #0069d3), color-stop(1, #007fff) );
  24.     background:-moz-linear-gradient( center top, #0069d3 5%, #007fff 100% );
  25.     filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#0069d3", endColorstr="#007fff");    
  26.     background: -o-linear-gradient(top,#0069d3,007fff);
  27.     background-color:#0069d3;
  28.     width: 140px;
  29.     height: 840px;
  30.     border-left: 2px solid #000000;
  31.     border-right: 2px solid #000000;
  32.     display: inline-table;
  33. }
  34.  
  35. div#nav li {     
  36.     text-decoration: none;       
  37.     display: block;     
  38. }
  39.  
  40.  ul#submenu li,
  41. div#nav li{         
  42.     background-color: #ce90dd;
  43.     border: 2px dashed #000000;     
  44.     border-left: 5px solid #000000;  
  45.     border-right: 5px solid #000000;   
  46.     border-bottom: 2px dashed #000000;
  47.     margin: 10px 0 10px 0;
  48.     margin-bottom: none;
  49.     width: 100px;
  50.     float: left;
  51.     padding: 15px;
  52.     height: 30; //tinggi block//
  53. }
  54.  
  55. div#nav li a:hover {
  56.     color: #FFFFFF;
  57.     background-color: #35af3b;
  58. }
  59.  
  60. ul#submenu {
  61.     display: none;
  62.     position:absolute;
  63.     margin-left:120px;
  64.     margin-top: -55px;
  65.     height:auto;
  66.     }
  67.  
  68. ul#myul li:hover > ul#submenu{
  69.     display: block;
  70.     }
  71.  
  72. ul#submenu li:hover{
  73.     color:#fff;
  74.     }
  75.  
  76. ul#submenu li a{
  77.     display:block; 
  78.     padding: 25px 40px;
  79.     color:#757575; 
  80.     text-decoration: none;
  81.     }

5 13397
Exequiel
288 256MB
try this, ,
css .....
Expand|Select|Wrap|Line Numbers
  1. div#nav{
  2.     text-align: center;
  3.     list-style: none;
  4.     font-size: 13px;
  5.     margin-bottom: none;
  6.     float: left;
  7.     padding-top: 5px;
  8. }
  9.  
  10. div#nav a {
  11.     text-decoration: none;
  12.     color: #000000;
  13.     display: block;
  14.     padding: 7px;
  15. }
  16.  
  17.  ul#submenu,
  18. div#nav ul#myul {     
  19.     list-style-type: none;     
  20.     padding-left: 0;     
  21.     margin-left: 10px;
  22.     background:-o-linear-gradient(bottom, #0069d3 5%, #007fff 100%);    
  23.     background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #0069d3), color-stop(1, #007fff) );
  24.     background:-moz-linear-gradient( center top, #0069d3 5%, #007fff 100% );
  25.     filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#0069d3", endColorstr="#007fff");    
  26.     background: -o-linear-gradient(top,#0069d3,007fff);
  27.     background-color:#0069d3;
  28.     width: 140px;
  29.     height: 840px;
  30.     border-left: 2px solid #000000;
  31.     border-right: 2px solid #000000;
  32.     display: inline-table;
  33. }
  34.  
  35. div#nav li {     
  36.     text-decoration: none;       
  37.     display: block;     
  38. }
  39.  
  40.  ul#submenu li,
  41. div#nav li{         
  42.     background-color: #ce90dd;
  43.     border: 2px dashed #000000;     
  44.     border-left: 5px solid #000000;  
  45.     border-right: 5px solid #000000;   
  46.     border-bottom: 2px dashed #000000;
  47.     margin: 10px 0 10px 0;
  48.     margin-bottom: none;
  49.     width: 100px;
  50.     float: left;
  51.     padding: 15px;
  52.     height: 30; //tinggi block//
  53. }
  54.  
  55. div#nav li a:hover {
  56.     color: #FFFFFF;
  57.     background-color: #35af3b;
  58. }
  59.  
  60. ul#submenu {
  61.     display: none;
  62.     position:absolute;
  63.     margin-left:120px;
  64.     margin-top: -55px;
  65.     height:auto;
  66.     }
  67.  
  68. ul#myul li:hover > ul#submenu{
  69.     display: block;
  70.     }
  71.  
  72. ul#submenu li:hover{
  73.     color:#fff;
  74.     }
  75.  
  76. ul#submenu li a{
  77.     display:block; 
  78.     padding: 25px 40px;
  79.     color:#757575; 
  80.     text-decoration: none;
  81.     }
Jan 15 '14 #2
Exequiel
288 256MB
html file...
Expand|Select|Wrap|Line Numbers
  1. <div id="nav">
  2.     <ul id="myul">
  3.         <li><a href="admin.php">HOME</a></li><br>
  4.         <li><a href="#">USER</a>
  5.             <ul id="submenu"> 
  6.                  <li><a href="new.php"> Add New User</a></li>
  7.                  <li><a href="#"> Choose User</a></li>
  8.             </ul>
  9.         </li>
  10.  
  11.         <li><a href="#">Pengesah</a></li><br>
  12.         <li><a href="#">Penyedia</a>
  13.             <ul id="submenu"> 
  14.                  <li><a href="new.php"> Add New User</a></li>
  15.                  <li><a href="#"> Choose User</a></li>
  16.             </ul>
  17.  
  18.         </li><br>
  19.         <li><a href="#">UPDATE</a></li><br>
  20.         <li><a href="logout.php">LOGOUT</a></li>
  21.     </ul>
  22. </div>
Jan 15 '14 #3
leesyaa
20
it works! thanks! :D
Jan 15 '14 #4
Exequiel
288 256MB
no problem, , :) goodluck...
Jan 15 '14 #5
Hi,
This css code also try do check
Expand|Select|Wrap|Line Numbers
  1. #menu{width:800px;height:82px;background-color:#666666;margin:0px 0px 0px 0px; border-radius:30px; text-align:center;}
  2. #menu ul {margin:0px;padding:0px;}
  3. #menu ul li{ border-radius:0px;float:left;list-style:none;margin:0px 4px 0px 4px; width:191px; padding-top:30px; height:50px;background-color:#99CC00; position:relative;}
  4. #menu ul li a{ text-decoration: none !important;}
  5. #menu ul li:hover{display:inline;background-color:#CCCCCC;border-radius:0px;margin:0px 4px 0px 4px; width:191px; height:45px;}
  6.  
  7.  
  8. /* first select menu */
  9.  
  10. ul.sub li{ background-color:#00CCFF; display:inline; }
  11. ul.sub li{margin:25px 0px 0px 0px; padding:0px 10px 0px 0px; position:absolute; }
  12. .hover ul.sub li{ display: block;position:relative;/*relative*/ float:none; margin:0px 0px 0px 29px;
  13. padding:3px 2px 2px 0px;  width:150px; height:20px;  }
  14.  
  15. /* second select menu */
  16. .second li{ display:none;position:relative; float:none;  height:35px;
  17. margin:1px 0px 0px 8px;     padding:10px 0px 10px 0px;}
  18. .second li{ display: block; background-color:red; }
  19. .second{ position:relative; height:35px; margin:0px 0px 0px 4px;     padding:0px 0px 0px 0px;}
  20.  
Jan 29 '14 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Sander Tekelenburg | last post by:
Trying to make some images disappear on hover (works), and others appear on hover (works not). In tested browsers, this gives the expected result: IMG.disappear {visibility: visible}...
6
by: Michael Rozdoba | last post by:
I've had some trouble getting IE to behave in respect of applying absolute positioning to a span on an a:hover. I can get it to work, but I don't understand why certain code causes it to fail to...
51
by: madsgormlarsen | last post by:
I can not get hover effect on a TD to work in IE, it seams you can not have a hover on a td in IE? I have treid this body.section-2 td.current, body.section-2 td.submenu, body.section-2...
5
by: Jonathan | last post by:
Hello All, I am in the process of creating a 2/3 level collapsible/exspanible menu (called "nav") where users can click on a category and have the submenus appear beneath it and so on (allow...
1
by: bhosalevivek | last post by:
I did this code from Dynamic Drive DHTML. it's working properly, but now I need submenu for "Submenu 1.2", means when I take mouse on "Submenu 1.2" I need to display "Submenu 1.2.1". I try to do...
8
by: Meri | last post by:
Hello Everybody on the internet seems to think this is a problem with IE but for me it works fine with IE, but the submenus do not appear with Firefox andOpera. The html is a simple list with...
1
oll3i
by: oll3i | last post by:
i have written css tab menu but my links in submenu inherit the style of a href in main menu (#menu ul li a)? when i hover over the links in submenu they do change as i want them to change they...
1
omerbutt
by: omerbutt | last post by:
hi every one i have a menu li and ul based the problem is when any specific category in the li is hovered the li or the sub-cat items appear but as i move my mouse over the sub-cat or level two li it...
6
KeredDrahcir
by: KeredDrahcir | last post by:
I am using a list to create a Main Menu with a drop down submenu. I need to able to using the hover pseudo class to display the drop down menu but IE6 only allows it on anchors. Is there a work round...
2
by: davidraimosson | last post by:
Hi! For a couple of days I've been trying to use Selenium to automate testing of a website. This fails because of a hidden menu item that is only displayed when the parent item in the menu is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.