Log in

View Full Version : Linking Divs (+rep)



Black_Apalachi
13-11-2008, 01:18 AM
At the moment my navigation is just a div for each link with the link's image as the background. I've also created rollovers so the background changes when the mouse rolls onto it.

I now want to obviously put links in these divs so they actually work.

I know that you need either text or an image in the div to be the link so I thought I'd be clever and make a transparrent .gif the size of the div. This works but it squashes the image up into the corner (on Firefox it becomes a thin grey box and on IE it just shows the red cross icon).

Does anyone know how to sort this or is it possible to make the div itself a link?

Thanks :).

HabbDance
13-11-2008, 01:28 AM
you didn't exactly make this clear, but im fairly sure that this would work:



<a href='url'><div id="id"></div></a>

Black_Apalachi
13-11-2008, 01:36 AM
+rep to you once again my friend!!! :D

Edit: Need to spread

L?KE
13-11-2008, 04:23 PM
Nooo don't do that, it's not valid as far as I can remember. (Would be habbdance.. :rolleyes:)

Change the width and heigh elements of the a tag to what you want and add rollovers that way.

L?KE
13-11-2008, 04:23 PM
Nooo don't do that, it's not valid as far as I can remember. (Would be habbdance.. :rolleyes:)

Change the width and heigh elements of the a tag to what you want and add rollovers that way.

Black_Apalachi
13-11-2008, 04:58 PM
Nooo don't do that, it's not valid as far as I can remember. (Would be habbdance.. :rolleyes:)

Change the width and heigh elements of the a tag to what you want and add rollovers that way.

When you say "not valid", does that mean it won't work? Because it did, like a charm :P. Anyway I'll try and see if I can understand your idea and give it a go :).

L?KE
13-11-2008, 05:02 PM
No I mean not valid as in..
http://validator.w3.org/

:P

Black_Apalachi
13-11-2008, 05:05 PM
No I mean not valid as in..
http://validator.w3.org/

:P

Oh, what happens if it's not then?

And do you mean just have a rollover image rather than a rollover background?

L?KE
13-11-2008, 05:11 PM
No you can assign what you gave the div to the a, eg:



a {
width: whatever px;
height: whatever px;
margin: 0;
padding: 3px;
text-align: center;
/* ETC... */
}


And also validation is basically just rules you have to obide by when coding, even if it displays properly.

Black_Apalachi
13-11-2008, 05:13 PM
No you can assign what you gave the div to the a, eg:



a {
width: whatever px;
height: whatever px;
margin: 0;
padding: 3px;
text-align: center;
/* ETC... */
}
And also validation is basically just rules you have to obide by when coding, even if it displays properly.

Oh I have all that thanks :).

Do you mean have to as in legally or something?

L?KE
13-11-2008, 10:10 PM
Well if you can achieve it in all browser and it's not valid, then I guess you don't have to.

But in terms of being a web designer and stuff you're gona need to validate in order to get clients etc.

In fairness I don't know exactly why it's there so if someone better than me :P cares to explain..?

HabbDance
13-11-2008, 10:22 PM
Well if you can achieve it in all browser and it's not valid, then I guess you don't have to.

But in terms of being a web designer and stuff you're gona need to validate in order to get clients etc.

In fairness I don't know exactly why it's there so if someone better than me :P cares to explain..?
Not better then you, but I'll still try to explain :D
Well code being valid is more appealing to clients because they think it's perfect. But tbh, you can have something valid and completely wrong. I don't normally care about validating for my own sites but when I sell or release I try my best. Don't kill yourself over it though.

Black_Apalachi
13-11-2008, 10:28 PM
Not better then you, but I'll still try to explain :D
Well code being valid is more appealing to clients because they think it's perfect. But tbh, you can have something valid and completely wrong. I don't normally care about validating for my own sites but when I sell or release I try my best. Don't kill yourself over it though.

Okies lol.

Want to hide these adverts? Register an account for free!