January 7th, 2005, 06:27 AM
|
#1 (permalink)
| | Registered User
Join Date: Oct 2001
Posts: 4,097
| css linking background image?
I have set a background-image in css. I'm wondering if it would be possible to turn this background-image into a link too? (im hoping to save myself some work)
Last edited by ClubMed : January 7th, 2005 at 06:31 AM.
|
| |
January 7th, 2005, 06:57 AM
|
#2 (permalink)
| | Ultimate Member
Join Date: Dec 2004
Posts: 1,558
|
I'm not entirely sure what you want accomplished but the answer is maybe. If you have a defined element, it can be a link. If it's just a background-image, probably not. If you are willing to share your source code and can better describe what you want, I can probably help. Here is a basic example how to turn an element into a link using javascript : |
| |
January 7th, 2005, 07:46 AM
|
#3 (permalink)
| | Registered User
Join Date: Oct 2001
Posts: 4,097
|
Here's my css code for the banner: Code: #banner {
font-family: Verdana, Arial, sans-serif;
color: #FFFFFF;
background-color: #66442A;
background-image: url(banner.gif);
text-align: left;
padding: 15px;
border-bottom: 0px solid #FFFFFF;
height: 169px;
} This is a banner that is displayed on all pages. As you can see, banner.gif is the background-image of the actual banner area. Only later did I realise that it would have been nicer to make the banner image a link back to the main site.
So to save myself the work of removing the background-image and pasting an image into the banner (+ all the work of reajusting the dimensions etc...) I was wondering if I could cheat somehow and just turn the background-image into a link, or perhaps i could turn the whole banner area (regardless of image) into a link? |
| |
January 7th, 2005, 07:57 AM
|
#4 (permalink)
| | Ultimate Member
Join Date: Dec 2004
Posts: 1,558
|
Probably the best way to do it is to use a filler image (a transparent GIF that is 1x1px). Put the image in the area where your banner is at, and then give it the height= and width= attributes to have it the same size as the banner and make it a link. Something kinda like this: Code: <A HREF="yourlinkhere"><img src="filler.gif" width="100" height="169" border="0"></A> Stick that in the area where your banner will appear and you now have a link. |
| |
January 7th, 2005, 10:05 AM
|
#5 (permalink)
| | Registered User
Join Date: Oct 2001
Posts: 4,097
|
ah i like that idea, thanks! |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | |
Similar Threads | | Thread | Thread Starter | Forum | Replies | Last Post | | frontpage problems | nishark | Webmastering and Programming | 4 | January 19th, 2003 03:00 AM | | Most Active Discussions | | | | | Recent Discussions  | | | | | |