Forum Moderators: not2easy

Message Too Old, No Replies

Making background images linkable

         

hgerman

8:23 pm on Feb 15, 2008 (gmt 0)

10+ Year Member



Hi folks! I'm building a Website in CSS and am pleased with everything I have done thus far. I have a background image on every page whose appearance is powered by a CSS file, which I call background.css, and sits in my css folder.

So the code on the html page reads: <link rel="stylesheet" type="text/css" href="css/background.css"/>

The code inside this file reads:

<!--
body { background-image: url(http://www.mywebsite.com/images/main-image.jpg); background-repeat: no-repeat; background-position: center top}
-->

I'm happy with everything, now I just need to make this background image linkable. I would like for people to click on this background image and have them go to the homepage, "mywebsite.com." How can I do this? Also, because this is a background image, it doesn't come out in print outs like all of the other images. Is there a way for a background image to show up in print outs?

birdbrain

12:26 pm on Feb 16, 2008 (gmt 0)



Hi there hgerman,

you cannot, as such, make a background-image a link.

In your case, though, this could be achieved by placing the a element over the background-image as in this example....


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
body {
background-image:url(http://www.searchengineworld.com/gfx/logo.png);
background-repeat:no-repeat;
background-position:center top;
margin-top:0;
}
#link {
width:109px; /*this width will be equal to the background image width*/
height:56px; /*this height will be equal to the background image height*/
margin:auto;
}
#link a {
width:100%;
height:100%;
display:block;
}
</style>

</head>
<body>

<div id="link">
<a href="http://www.webmasterworld.com/css/3576144.htm"></a>
</div>

</body>
</html>

birdbrain

birdbrain

12:50 pm on Feb 16, 2008 (gmt 0)



Hi there hgerman,


Is there a way for a background image to show up in print outs?

You cannot force users to print images.
That will always remain there choice as they have to pay for the ink. ;)

Of course,if you want to print them, then you must set your options to print them.

IE procedure...

  1. click 'Tools'.
  2. click 'Internet Options'.
  3. click 'Advanced'.
  4. scroll down to 'Printing'.
  5. check 'Print background colors and images'

Firefox procedure...
  1. click 'File'.
  2. click 'Page Setup...'.
  3. click 'Format & Options'.
  4. check 'Print Background (colors & images).

birdbrain

hgerman

8:04 pm on Feb 21, 2008 (gmt 0)

10+ Year Member



thanks!

birdbrain

1:17 am on Feb 22, 2008 (gmt 0)



No problem, you're welcome. ;)