- Moderated by:
- Support Team
-
- rank:
-
Softmore
- registered:
- August 2006
- Status:
- offline
- last visit:
- 21.11.08
- Posts:
- 59
Hi folks,
I'm a CSS noob looking for help, and I'm guessing most of you could solve this with your eyes closed.
I've been trying to link the logo image that appears in the header of our website to the home page. The problem for me is that the image is called within CSS, and then the header block called by the HTML template. I've scoured the Internet for the proper syntax of linking a CSS background image without success.
FYI, the call for the image within CSS is coded as follows in the style sheet:
Code
#fpic
{
width: 686px;
border: 1px inset #888;
height: 200px;
background-color: #999999;
clear: both;
background: url('../images/header.jpg') no-repeat;
}
and the call within the HTML template is as follows:
Code
<!-- This layer contains the pic(background), and a right side menu -->
<div id="fpic">
Help? Thanks a bunch in advance. -
- rank:
-
Professional
- registered:
- September 2006
- Status:
- offline
- last visit:
- 22.11.08
- Posts:
- 1451
Right!
I understand that you want to use the image in your HTML...
you have to know that the paths used in the CSS are relative to the CSS file; if you don't know what it means: "../images" path means that you have to go out of the folder where the style is and search fot a folder called images... and there is the header.jpg
Your links must be as:
Code
<img src="themes/YOURTHEMENAME/images/header.jpg" alt="..." width=".." height=".." />
--
- Mateo T. -
Mis principios... son mis fines -
- rank:
-
Softmore
- registered:
- August 2006
- Status:
- offline
- last visit:
- 21.11.08
- Posts:
- 59
Actually, not quite, but thanks for the reply nonetheless. I understand the relative/absolute path thing. That's not the problem. The photo displays just fine.
What I want to do is activate a URL within the photo, in other words I want the user to go to a different URL when clicking on the image that's displayed via the CSS quoted in my original message above. Normally in HTML I'd code it this way:
Code
<a href="http://www.somedomain.com/"><img src="http://www.somedomain.com/image.jpg"></a>
However, I can't figure out how to create the link given that the image is called via CSS, as I'm not familiar enough with CSS and can't find the proper CSS to do so referenced anywhere. If someone clicks on this header image I want them to be re-routed back to our home page. -
- rank:
-
Professional
- registered:
- September 2006
- Status:
- offline
- last visit:
- 22.11.08
- Posts:
- 1451
Ouh, i think there's no solution for what you want.
CSS is not for define links... may exist a form to do this, but i recommend you to modify the HTML instead use CSS for not-design aims...
you may use onclick in your div, or insert a link tag into the div and with CSS expand it with CSS (padding, may be width, height, position, top, left... ), but IMHO an A tag like this:with padding or widht/height defined in the CSS can be a solution for you.Code
<a href="yoursiteurl"> </a>
Good luck
--
- Mateo T. -
Mis principios... son mis fines -
- rank:
-
Softmore
- registered:
- August 2006
- Status:
- offline
- last visit:
- 21.11.08
- Posts:
- 59
Bingo! Thanks for pointing me in the right direction, and I learned a bit of JavaScript event handling in the process.
Here's how I coded it (after googling on how to get the mouse pointer to change to a hand, too):
Code
<!-- This layer contains the pic(background), and a right side menu -->
<div id="fpic" onclick='window.location.href="http://www.myhomepage.com/";;'>
-
- rank:
-
Professional
- registered:
- September 2006
- Status:
- offline
- last visit:
- 22.11.08
- Posts:
- 1451
Good!
you have to search the best practices using JavaScript, and in my experience, after the redirection return false...
Styling the cursor is easy but not cross-browser compatible at all...
cursor: hand, pointer;
if i remember good, it's the way to change the cirsor to a hand, and if isn't then use the normal pointer...
See you in the community!
--
- Mateo T. -
Mis principios... son mis fines -
- rank:
-
Professional
- registered:
- February 2004
- Status:
- offline
- last visit:
- 01.11.08
- Posts:
- 1037
-
- rank:
-
Professional
- registered:
- September 2006
- Status:
- offline
- last visit:
- 22.11.08
- Posts:
- 1451
Yes, finally the best solution is move the image to the HTML.
--
- Mateo T. -
Mis principios... son mis fines

