/    Sign up×
Community /Pin to ProfileBookmark

HTML/CSS problem, need to place links into hover div

Ok, I’m very much new to this stuff, the following code is the first I’ve ever written. Please be kind… I get the logic of what I’m doing and how web sites work, but nowhere near enough experience to do things ‘the right way’!

Anyway I am trying to create a drop down ‘mega menu’ element using only CSS and html, with each drop down containing images, text and crucially links. I have created the effect I’m happy with, but as soon as I try and add links into the drop down divs the whole effect corrupts.

Is this even possible the way I have started to do this?

Here is the code (once working I’ll add to the main site and pop the CSS into the associated CSS for that site).

Effect working as should do:

[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
<style type=”text/css”>
<!–

body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
#apDiv4 {
position:relative;
width:375px;
height:115px;
z-index:1;
background-color:#FF33FF;
}

–>
</style>
</head>

<body>

<style type=”text/css”>
<!–
#apDiv1 {
position:absolute;
top:0px;
text-align:center;
font-family: tahoma;
font-size:12px;
font-weight:bold;
background-color:inherit;
border-right-width:1px;
border-right-style:groove;
width:149px;
border-right-color:#0390c8;
padding-right:-1px;
height:1em;
padding-bottom:1em;
padding-top:.7em;
z-index:1;
}
#apDiv2 {
position:absolute;
top:0px;
text-align:center;
font-family: tahoma;
font-size:12px;
font-weight:bold;
background-color:#009ddc;
border-right-width:1px;
border-right-style:groove;
width:9px;
border-right-color:#0390c8;
padding-right:-1px;
height:1em;
padding-bottom:1em;
padding-top:.7em;
z-index:1;
-moz-border-radius-topleft:4px;
-moz-border-radius-bottomleft:4px;
border-bottom-left-radius: 4px 4px;
border-bottom-left-radius: 4px 4px;
border-top-left-radius: 4px 4px;
border-top-left-radius: 4px 4px;
}

#apDiv3 {
position:absolute;
top:0px;
text-align:center;
font-family: tahoma;
font-size:12px;
font-weight:bold;
background-color:#009ddc;
border-right-width:1px;
border-right-style:groove;
width:9px;
border-right-color:#0390c8;
padding-right:-1px;
height:1em;
padding-bottom:1em;
padding-top:.7em;
z-index:1;
-moz-border-radius-topright:4px;
-moz-border-radius-bottomright:4px;
border-bottom-right-radius: 4px 4px;
border-bottom-right-radius: 4px 4px;
border-top-right-radius: 4px 4px;
border-top-right-radius: 4px 4px;
}
–>
</style>

<table width=”920px” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td width=”10px”><p><a href=”#”><div id=”apDiv2″></div></td>

<td><p><a class=”style1″><div id=”apDiv1″>Aquarium</div><span class=”style1″>Pond stuff edf ewf ewfkew fe wf ewjfehfehuf ewhfehwofheohfoehwfo hewfew fhewfhoewhfoehwfo hwofheow hfoewhfewfhewhfo ewofh oewhfoe whf hewohfoewh fo ew </span></a>.</td>
<td><p><a href=”#” class=”style1″><div id=”apDiv1″>Pond</div><span class=”style1″>Pond stuff edf ewf ewfkew fe wf ewjfehfehuf ewhfehwofheohfoehwfo hewfew fhewfhoewhfoehwfo hwofheow hfoewhfewfhewhfo ewofh oewhfoe whf hewohfoewh fo ew fhehw f hewhf oewh fehwof heowih foehwfo hewofhoewhofihewi fhewih fioe wfo iew hfewioh fioew hfew hfoehfeowhfew hofi</span></a>.</td>
<td><p><a href=”#” class=”style1″><div id=”apDiv1″>Complete Aquariums</div><span class=”style1″>Pond stuff edf ewf ewfkew fe wf ewjfehfehuf ewhfehwofheohfoehwfo hewfew fhewfhoewhfoehwfo hwofheow hfoewhfewfhewhfo ewofh oewhfoe whf hewohfoewh fo ew fhehw f hewhf oewh fehwof heowih foehwfo hewofhoewhofihewi fhewih fioe wfo iew hfewioh fioew hfew hfoehfeowhfew hofi</span></a>.</td>
<td><p><a href=”#” class=”style2″><div id=”apDiv1″>Water Features</div><span class=”style1″>Pond stuff edf ewf ewfkew fe wf ewjfehfehuf ewhfehwofheohfoehwfo hewfew fhewfhoewhfoehwfo hwofheow hfoewhfewfhewhfo ewofh oewhfoe whf hewohfoewh fo ew fhehw f hewhf oewh fehwof heowih foehwfo hewofhoewhofihewi fhewih fioe wfo iew hfewioh fioew hfew hfoehfeowhfew hofi</span></a>.</td>
<td><p><a href=”#” class=”style2″><div id=”apDiv1″>Books</div><span class=”style1″>Pond stuff edf ewf ewfkew fe wf ewjfehfehuf ewhfehwofheohfoehwfo hewfew fhewfhoewhfoehwfo hwofheow hfoewhfewfhewhfo ewofh oewhfoe whf hewohfoewh fo ew fhehw f hewhf oewh fehwof heowih foehwfo hewofhoewhofihewi fhewih fioe wfo iew hfewioh fioew hfew hfoehfeowhfew hofi</span></a>.</td>
<td><p><a href=”#” class=”style2″><div id=”apDiv1″>biOrb</div><span class=”style1″>text text text text text text</span></a>

.</td>
<td width=”10px”><p><a href=”#”><div id=”apDiv3″></div></td>
</tr>
</table>

<style type=”text/css”>
<!–

.style1 {background-color: inherit;}

a.style1 {
text-decoration: none;
display:block;
color:#FFFFFF;
background-color: #009ddc;
}

a.style1:hover {
position: absolute;
top: 0px;
display:block;
color:#FFFFFF;
background-color: #0062a6;

}

a.style1 span {
display: none;
}

a.style1:hover span {
display: block;
position: absolute;
top: -1em;
/* formatting only styles */
padding: 5px; left: 0px; width:400px; margin-top:3em; z-index: 100;
background: #0062a6;
-moz-border-radius-bottomleft:12px;
-moz-border-radius-bottomright:12px;
-moz-border-radius-topleft:0px;
-moz-border-radius-topright:12px;
border-bottom-left-radius: 12px 12px;
border-bottom-left-radius: 12px 12px;
border-bottom-right-radius: 12px 12px;
border-bottom-right-radius: 12px 12px;
border-top-right-radius: 12px 12px;
border-top-right-radius: 12px 12px;
/* end formatting */
}

–>
</style>

<style type=”text/css”>
<!–

.style2 {background-color: inherit;}

a.style2 {
text-decoration: none;
display:block;
color:#FFFFFF;
background-color: #009ddc;
}

a.style2:hover {
position: absolute;
top: 0px;
display:block;
color:#FFFFFF;
background-color: #0062a6;

}

a.style2 span {
display: none;
}

a.style2:hover span {
display: block;
position: absolute;
top: -1em;
/* formatting only styles */
padding: 5px; right: -149px; width:400px; margin-top:3em; z-index: 100;
background: #0062a6;
-moz-border-radius-bottomleft:12px;
-moz-border-radius-bottomright:12px;
-moz-border-radius-topleft:12px;
-moz-border-radius-topright:0px;
border-bottom-left-radius: 12px 12px;
border-bottom-left-radius: 12px 12px;
border-bottom-right-radius: 12px 12px;
border-bottom-right-radius: 12px 12px;
border-top-left-radius: 12px 12px;
border-top-left-radius: 12px 12px;
/* end formatting */
}

–>
</style>

</p>

</body>
</html>

[/CODE]

My problem is I cannot add any links into those hovering drop down boxes without losing everything – any help much appreciated in advance!

Thanks

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@nodeheadJul 07.2010 — You've quite a few validation errors, so you'll want to start by tidying up your mark-up: http://validator.w3.org/

The most apparent errors are the block-level elements (e.g. div) within strict inline elements (e.g. anchors), and failure to close (or possible improperly nest, I didn't look that close) a lot of tags (seen some P tags and some Anchors)

There's other problems, but get your document validating and you'll have a better chance of trouble-shooting it.
Copy linkTweet thisAlerts:
@tirnaJul 08.2010 — I agree with nodehead.

Your code, as posted, spits out 49 errors in the w3c validator.

All the styles first need to be put in the <head> and you also have elements used in incorrect places and some tags are not closed properly.

I think the first thing that needs to be done is to get your html to pass validation and then add in additional features or effects.
×

Success!

Help @movietub spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...