July 21, 200818 yr Hi guys. I have a site where i want one part of my site that is in a div container with a background image to be a link that when it's clicked it goes to my goldstein media site. It pretty much looks like this <div id="rightHeader"> </div> now in the CSS it looks like this #rightHeader { width:191px; height:168px; float:left; background-image:url(../images/main/otdalt_03.jpg); } now I want when the person clicks that empty div that's not really empty it goes to my site. is there a way to make a <div> hot? Please let me know Thanks!
July 21, 200818 yr Hi Seth I may be being dippy (I'm no CSS expert, but I am awake so you're stuck until the others wake up!) Can't you just put an image surrounded by an anchor tag with the link in it? The anchor and image can then be floated any way you want. Assuming a parent container of #header you have: <div id="header"> blah blah blah <a href="htttp://...."><img src="../images/main/otdalt_03.jpg" /></a> </div> Or am I missing something?
July 21, 200818 yr You can just put the <a> tags arround your div <a href"="http://mysite.com"> <div id="rightHeader"> </div> </a> Haven't checked if HTML Validator will complain though
July 21, 200818 yr @rdjejong A block element nested inside an inline element? I'm sure the validator will throw a wobbler! @Seth Definitely try to do what wizely suggested. If that isn't practical for you, you could create a 'false' link over the background image. Define your header as position:relative; Then have a link inside the header positioned absolutely. HTML <div id="header"> <a id="myfalselink" href="mypage.html" title="go to my page">My Page</a> </div> #header { position:relative; } #header a#myfalselink { position:absolute; display:block; height: the height of your header; width: the width of the background image you want to 'cover'; top:0; /*position it at the top of the header*/ right:0; /*position it at the right of your header*/ text-indent:-5000px; /*make the anchor text disappear*/ }
July 21, 200818 yr Author Hi Seth I may be being dippy (I'm no CSS expert, but I am awake so you're stuck until the others wake up!) Can't you just put an image surrounded by an anchor tag with the link in it? The anchor and image can then be floated any way you want. Assuming a parent container of #header you have: <div id="header"> blah blah blah <a href="htttp://...."><img src="../images/main/otdalt_03.jpg" /></a> </div> Or am I missing something? Thanks guys for all your help. Wizely, the main reason why I don't want to make a graphic and put an anchor on it is that this site has possibly 60 pages and everything I have to make a flipping stuctural change it takes me a god awful amount of time. I was hoping there was a way where all I had to do was mess with the css. But I guess that's not so. Now I understand why PHP is a good thing to know because you can separate your header and footer into it's own document and just call it up when you need it. I wish there were a way to do this in CSS. Hmmmm, maybe CSS 3. Thanks guys!
July 23, 200818 yr The code you are/were looking for is: take out the space: <div id="rightHeader"><a href="#" title=""></a></div> now the CSS: #rightHeader{ width:191px; height:168px; float:left; } #rightHeader a, #rightHeader a:link, #rightHeader a:visited, #rightHeader a:hover, #rightHeader a:active{ width:100%; height:100%; display:block; outline:none; background-image:url(../images/main/otdalt_03.jpg); } That does the trick. If you want the image to change on rollover then just copy the last block of CSS but just leave the "#rightHeader a:hover" as the identifier and change the image (or shift the image down so you dont need to preload) Hope I'm not too late with this post. Liam
July 23, 200818 yr That does the trick. If you want the image to change on rollover then just copy the last block of CSS but just leave the "#rightHeader a:hover" as the identifier and change the image (or shift the image down so you dont need to preload) Hope I'm not too late with this post. Liam hmm why have I never thought of that? I used to put a 1px X 1px transparent spacer gif in there and set it to 100% W&H and just put the a href on that or map it out. but your way sounds so much cooler
Create an account or sign in to comment