Make drop down menus cover text and stay active onclick
- Jan Jeremy Go
- Newbie


- Joined: Oct 20, 2010
- Posts: 13
- Loc: Philippines
- Status: Offline
Hi guys, I need help!
Q1:
Do you know how can I make my drop down menus "<div id=submenu>" overlap/cover the text in "<div id=container>"? I use "z-index:", but no effect!
Q2:
How can I make my menu stay active when on click, in FireFox: "active" only occur when on click but after that back to "hover", unlike Internet Explorer it will stay but many not possible to do like "div:hover". Maybe I need to use "onclick" or sometime? But I don't how to make drop down menu with that.
Q3:
How can I position my time in right side without destruction, I use "float:right" but the format I want is single line, but it create 2 lines. Is there such "left:" and "top:"? right?
Please help, if you answer my questions, and here's my code:
Hey don't forget to put DOCTYPE on the top of your codes!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www. .org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
.......//www.w3.or...
Thank you in advance for helping/guiding/telling me!!!
Q1:
Do you know how can I make my drop down menus "<div id=submenu>" overlap/cover the text in "<div id=container>"? I use "z-index:", but no effect!
Q2:
How can I make my menu stay active when on click, in FireFox: "active" only occur when on click but after that back to "hover", unlike Internet Explorer it will stay but many not possible to do like "div:hover". Maybe I need to use "onclick" or sometime? But I don't how to make drop down menu with that.
Q3:
How can I position my time in right side without destruction, I use "float:right" but the format I want is single line, but it create 2 lines. Is there such "left:" and "top:"? right?
Please help, if you answer my questions, and here's my code:
Hey don't forget to put DOCTYPE on the top of your codes!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www. .org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
.......//www.w3.or...
HTML Code: [ Select ]
<html>
<head>
<title>My_Site</title>
</head>
<body onload="startTime()">
<div>
<div>
<div>
<a class="menu" title="Home" href="#Home">Home</a>
<div>
<a class="submenu" title="" href="#Home_Wall">Wall</a>
<a class="submenu" title="" href="#Home_Profile">
Profile</a>
<a class="submenu" title="" href="#Home_PM's">PM's</a>
<a class="submenu" title="" href="#Home_Security and
Privacy">Security and Privacy</a>
</div>
</div>
<div>
<a class="menu" title="Forum" href="#Forum">Forum</a>
<div>
<a class="submenu" title="" href="#Forum_Programs">Programs</a>
<a class="submenu" title="" href="#Forum_Friends">Friends</a>
<a class="submenu" title="" href="#Forum_Games">Games</a>
</div>
</div>
<div>
<a class="menu" title="Help" href="#Help">Help</a>
<div>
<a class="submenu" title="" href="#Help_FAQ">FAQ</a>
<a class="submenu" title="" href="#Help_Ask Help Online">
Ask Help Online</a>
</div>
</div>
<div>
<a class="menu" id="right" title="Log Out" href="#Log Out">Log Out</a>
</div>
</div>
<div id="container">
<p><h1>Welcome!</h1></p>
<p>With this site, you'll learn many thing that you want to
learn, but only that is all is available!<p>
</div>
<div id="special"><div id="txt"></div></div>
</div>
</body>
</html>
<head>
<title>My_Site</title>
</head>
<body onload="startTime()">
<div>
<div>
<div>
<a class="menu" title="Home" href="#Home">Home</a>
<div>
<a class="submenu" title="" href="#Home_Wall">Wall</a>
<a class="submenu" title="" href="#Home_Profile">
Profile</a>
<a class="submenu" title="" href="#Home_PM's">PM's</a>
<a class="submenu" title="" href="#Home_Security and
Privacy">Security and Privacy</a>
</div>
</div>
<div>
<a class="menu" title="Forum" href="#Forum">Forum</a>
<div>
<a class="submenu" title="" href="#Forum_Programs">Programs</a>
<a class="submenu" title="" href="#Forum_Friends">Friends</a>
<a class="submenu" title="" href="#Forum_Games">Games</a>
</div>
</div>
<div>
<a class="menu" title="Help" href="#Help">Help</a>
<div>
<a class="submenu" title="" href="#Help_FAQ">FAQ</a>
<a class="submenu" title="" href="#Help_Ask Help Online">
Ask Help Online</a>
</div>
</div>
<div>
<a class="menu" id="right" title="Log Out" href="#Log Out">Log Out</a>
</div>
</div>
<div id="container">
<p><h1>Welcome!</h1></p>
<p>With this site, you'll learn many thing that you want to
learn, but only that is all is available!<p>
</div>
<div id="special"><div id="txt"></div></div>
</div>
</body>
</html>
- <html>
- <head>
- <title>My_Site</title>
- </head>
- <body onload="startTime()">
- <div>
- <div>
- <div>
- <a class="menu" title="Home" href="#Home">Home</a>
- <div>
- <a class="submenu" title="" href="#Home_Wall">Wall</a>
- <a class="submenu" title="" href="#Home_Profile">
- Profile</a>
- <a class="submenu" title="" href="#Home_PM's">PM's</a>
- <a class="submenu" title="" href="#Home_Security and
- Privacy">Security and Privacy</a>
- </div>
- </div>
- <div>
- <a class="menu" title="Forum" href="#Forum">Forum</a>
- <div>
- <a class="submenu" title="" href="#Forum_Programs">Programs</a>
- <a class="submenu" title="" href="#Forum_Friends">Friends</a>
- <a class="submenu" title="" href="#Forum_Games">Games</a>
- </div>
- </div>
- <div>
- <a class="menu" title="Help" href="#Help">Help</a>
- <div>
- <a class="submenu" title="" href="#Help_FAQ">FAQ</a>
- <a class="submenu" title="" href="#Help_Ask Help Online">
- Ask Help Online</a>
- </div>
- </div>
- <div>
- <a class="menu" id="right" title="Log Out" href="#Log Out">Log Out</a>
- </div>
- </div>
- <div id="container">
- <p><h1>Welcome!</h1></p>
- <p>With this site, you'll learn many thing that you want to
- learn, but only that is all is available!<p>
- </div>
- <div id="special"><div id="txt"></div></div>
- </div>
- </body>
- </html>
JAVASCRIPT Code: [ Select ]
<script type="text/javascript">
function startTime()
{
var today= new Date();
var h= today.getHours();
var m= today.getMinutes();
var s= today.getSeconds();
var d;
// add a zero in front of numbers<10
d = checkPerHalfDay(d, h);
h = checkIfMoreThanHalf(h);
h = checkTime(h);
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML = h + ":" + m + ":" + s + " " + d;
t = setTimeout('startTime()',500);
}
function checkPerHalfDay(d, h)
{
if (h < 12)
{
d = "am";
}
else
{
d = "pm";
}
return d;
}
function checkIfMoreThanHalf(h)
{
if (h > 12)
{
h = h - 12;
}
return h;
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
function startTime()
{
var today= new Date();
var h= today.getHours();
var m= today.getMinutes();
var s= today.getSeconds();
var d;
// add a zero in front of numbers<10
d = checkPerHalfDay(d, h);
h = checkIfMoreThanHalf(h);
h = checkTime(h);
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML = h + ":" + m + ":" + s + " " + d;
t = setTimeout('startTime()',500);
}
function checkPerHalfDay(d, h)
{
if (h < 12)
{
d = "am";
}
else
{
d = "pm";
}
return d;
}
function checkIfMoreThanHalf(h)
{
if (h > 12)
{
h = h - 12;
}
return h;
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
- <script type="text/javascript">
- function startTime()
- {
- var today= new Date();
- var h= today.getHours();
- var m= today.getMinutes();
- var s= today.getSeconds();
- var d;
- // add a zero in front of numbers<10
- d = checkPerHalfDay(d, h);
- h = checkIfMoreThanHalf(h);
- h = checkTime(h);
- m = checkTime(m);
- s = checkTime(s);
- document.getElementById('txt').innerHTML = h + ":" + m + ":" + s + " " + d;
- t = setTimeout('startTime()',500);
- }
- function checkPerHalfDay(d, h)
- {
- if (h < 12)
- {
- d = "am";
- }
- else
- {
- d = "pm";
- }
- return d;
- }
- function checkIfMoreThanHalf(h)
- {
- if (h > 12)
- {
- h = h - 12;
- }
- return h;
- }
- function checkTime(i)
- {
- if (i<10)
- {
- i="0" + i;
- }
- return i;
- }
- </script>
CSS Code: [ Select ]
<style type="text/css">
body
{
background-image: url('Diamond_Tiles.jpg');
background-position: top center;
margin: 30px;
padding: 0px;
width: 93%;
height: 100%;
}
.menu
{
font-family:"Times New Roman", Times, serif;
font-size: 23px;
font-weight: 700;
z-index: 1;
overflow: hidden;
}
.submenu
{
font-family:"Arial";
font-size: 16px;
font-weight: 600;
width: 100%;
height: 100%;
z-index: 1;
overflow: hidden;
}
div#container, div#container p
{
background-color: cyan;
z-index: -1;
}
#right
{
float: right;
}
#special
{
background-color: lightgreen;
height: 20px;
font-weight: 600;
}
div
{
background-color: black;
color: red;
margin: auto;
padding: 10px;
height: 500px;
}
div div
{
background-color: skyblue;
margin: auto;
padding: auto;
width: auto;
height: auto;
}
div div div
{
display: inline-block;
margin: auto;
padding: 0px;
vertical-align: top;
width: 24%;
height: 0px;
}
div div div div
{
display: none;
margin: auto;
padding: 0px;
width: 100%;
height: auto;
}
div div div:hover div
{
display: block;
margin: auto;
padding: 0px;
width: 100%;
height: auto;
}
div div div a
{
background-color: lime;
color: blue;
display: block;
text-decoration: none;
}
div div div a:hover
{
background-color: green;
color: gold;
display: block;
margin: 0px;
padding: 0px;
text-align: center;
text-decoration: none;
}
div div div a:active
{
background-color: red;
color: yellow;
display: block;
margin: 0px;
padding: 0px;
text-align: left;
text-decoration: none;
}
div div div div a
{
background-color: black;
color: skyblue;
display: block;
margin: 0px;
padding: 0px;
text-align: left;
text-decoration: none;
}
div div div div a:hover
{
background-color: silver;
color: cyan;
display: block;
margin: 0px;
padding: 0px;
text-align: left;
text-decoration: none;
z-index: 1;
}
div div div div a:active
{
background-color: cyan;
color: blue;
display: block;
margin: 0px;
padding: 0px;
text-align: left;
text-decoration: none;
}
</style>
body
{
background-image: url('Diamond_Tiles.jpg');
background-position: top center;
margin: 30px;
padding: 0px;
width: 93%;
height: 100%;
}
.menu
{
font-family:"Times New Roman", Times, serif;
font-size: 23px;
font-weight: 700;
z-index: 1;
overflow: hidden;
}
.submenu
{
font-family:"Arial";
font-size: 16px;
font-weight: 600;
width: 100%;
height: 100%;
z-index: 1;
overflow: hidden;
}
div#container, div#container p
{
background-color: cyan;
z-index: -1;
}
#right
{
float: right;
}
#special
{
background-color: lightgreen;
height: 20px;
font-weight: 600;
}
div
{
background-color: black;
color: red;
margin: auto;
padding: 10px;
height: 500px;
}
div div
{
background-color: skyblue;
margin: auto;
padding: auto;
width: auto;
height: auto;
}
div div div
{
display: inline-block;
margin: auto;
padding: 0px;
vertical-align: top;
width: 24%;
height: 0px;
}
div div div div
{
display: none;
margin: auto;
padding: 0px;
width: 100%;
height: auto;
}
div div div:hover div
{
display: block;
margin: auto;
padding: 0px;
width: 100%;
height: auto;
}
div div div a
{
background-color: lime;
color: blue;
display: block;
text-decoration: none;
}
div div div a:hover
{
background-color: green;
color: gold;
display: block;
margin: 0px;
padding: 0px;
text-align: center;
text-decoration: none;
}
div div div a:active
{
background-color: red;
color: yellow;
display: block;
margin: 0px;
padding: 0px;
text-align: left;
text-decoration: none;
}
div div div div a
{
background-color: black;
color: skyblue;
display: block;
margin: 0px;
padding: 0px;
text-align: left;
text-decoration: none;
}
div div div div a:hover
{
background-color: silver;
color: cyan;
display: block;
margin: 0px;
padding: 0px;
text-align: left;
text-decoration: none;
z-index: 1;
}
div div div div a:active
{
background-color: cyan;
color: blue;
display: block;
margin: 0px;
padding: 0px;
text-align: left;
text-decoration: none;
}
</style>
- <style type="text/css">
- body
- {
- background-image: url('Diamond_Tiles.jpg');
- background-position: top center;
- margin: 30px;
- padding: 0px;
- width: 93%;
- height: 100%;
- }
- .menu
- {
- font-family:"Times New Roman", Times, serif;
- font-size: 23px;
- font-weight: 700;
- z-index: 1;
- overflow: hidden;
- }
- .submenu
- {
- font-family:"Arial";
- font-size: 16px;
- font-weight: 600;
- width: 100%;
- height: 100%;
- z-index: 1;
- overflow: hidden;
- }
- div#container, div#container p
- {
- background-color: cyan;
- z-index: -1;
- }
- #right
- {
- float: right;
- }
- #special
- {
- background-color: lightgreen;
- height: 20px;
- font-weight: 600;
- }
- div
- {
- background-color: black;
- color: red;
- margin: auto;
- padding: 10px;
- height: 500px;
- }
- div div
- {
- background-color: skyblue;
- margin: auto;
- padding: auto;
- width: auto;
- height: auto;
- }
- div div div
- {
- display: inline-block;
- margin: auto;
- padding: 0px;
- vertical-align: top;
- width: 24%;
- height: 0px;
- }
- div div div div
- {
- display: none;
- margin: auto;
- padding: 0px;
- width: 100%;
- height: auto;
- }
- div div div:hover div
- {
- display: block;
- margin: auto;
- padding: 0px;
- width: 100%;
- height: auto;
- }
- div div div a
- {
- background-color: lime;
- color: blue;
- display: block;
- text-decoration: none;
- }
- div div div a:hover
- {
- background-color: green;
- color: gold;
- display: block;
- margin: 0px;
- padding: 0px;
- text-align: center;
- text-decoration: none;
- }
- div div div a:active
- {
- background-color: red;
- color: yellow;
- display: block;
- margin: 0px;
- padding: 0px;
- text-align: left;
- text-decoration: none;
- }
- div div div div a
- {
- background-color: black;
- color: skyblue;
- display: block;
- margin: 0px;
- padding: 0px;
- text-align: left;
- text-decoration: none;
- }
- div div div div a:hover
- {
- background-color: silver;
- color: cyan;
- display: block;
- margin: 0px;
- padding: 0px;
- text-align: left;
- text-decoration: none;
- z-index: 1;
- }
- div div div div a:active
- {
- background-color: cyan;
- color: blue;
- display: block;
- margin: 0px;
- padding: 0px;
- text-align: left;
- text-decoration: none;
- }
- </style>
Thank you in advance for helping/guiding/telling me!!!
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
November 4th, 2010, 9:10 am
- dycemen
- Born


- Joined: Nov 03, 2010
- Posts: 4
- Status: Offline
- Jan Jeremy Go
- Newbie


- Joined: Oct 20, 2010
- Posts: 13
- Loc: Philippines
- Status: Offline
- Jan Jeremy Go
- Newbie


- Joined: Oct 20, 2010
- Posts: 13
- Loc: Philippines
- Status: Offline
- Bogey
- Bogey


- Joined: Jul 14, 2005
- Posts: 8211
- Loc: USA
- Status: Offline
To be able to use z-index you need to define a position property in CSS.
CSS Code: [ Select ]
.overlappingTag {
position: relative;
z-index: 2;
}
.overlappedTag {
position: relative;
z-index: 1;
}
position: relative;
z-index: 2;
}
.overlappedTag {
position: relative;
z-index: 1;
}
- .overlappingTag {
- position: relative;
- z-index: 2;
- }
- .overlappedTag {
- position: relative;
- z-index: 1;
- }
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
- Jan Jeremy Go
- Newbie


- Joined: Oct 20, 2010
- Posts: 13
- Loc: Philippines
- Status: Offline
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 7 posts
- Users browsing this forum: No registered users and 155 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
