views:

443

answers:

2

Consider this page @ http://www.bloodbone.ws/screwed.html

I need to be able to have the a.grow element expand to the dimensions of the div.column-header so that if you target anywhere in the div the whole area is clickable.

It works in Firefox + Safari, but I can't get it to work in any IE browser.

The h2 and img elements always break the a.grow so there are areas that aren't clickable.

I've tried everything I can think of, adding zoom: 1 etc. to no avail.

The h2 and img have to be visible, but any mouse hover over the area should be clickable.

A: 

will

    <div class="column-header">
     <a class="grow" href="http://www.google.com"&gt;Google&lt;/a&gt;  
        <h2>What's On</h2>
     <a href="http://www.google.com"&gt;
      <img src='http://www.bloodbone.ws/images/mainHeader.jpg' alt='boo' />
     </a>
    </div>

do?

lock
It does, but it's invalid HTML
brendo
oh yes im sorry i didnt check that myself lols
lock
i edited the code, it seems you're trying to make it work for SEO right? i guess two anchors with different labels wont hurt...
lock
Yeah, it wouldn't hurt, but it doesn't completely fix the problem because the `h2` text 'breaks' the overlay as well.It's just one of these where you mind boggles because it SHOULD work and does (in Safari/FF) but for some reason IE trips up.
brendo
At the risk of sounding silly, but for the sake of expanding knowledge, what makes it invalid HTML?
Zoe
Delilah, I'm not aware of what you guys are talking about, but anchor doesn't allow img tags inside it, by "w3c laws".
yoda
+2  A: 

Hi,

To have it "SEO compatible", you have 2 options:

  1. Aplly several anchor tags to cover all your div;
  2. Use a framework like JQuery to make the div clickable (and when clicked follow the anchor href), and mantain the anchor inside the div for SEO purposes.
yoda
I use jQuery to do it in the end for IE.Still baffles me why a CSS solution isn't possible.
brendo
Well, css is possible actually, but its kinda risky .. The only w3c valid option with css is by creating a anchor tag with position absolute above the area you want, but that requires you to set a fixed position on the div (top and left always fixed) or use javascript to calculate the position of the div (not 100% loyal due to redimension of pages)
yoda
Why can't the `div` be set to `position: relative` and then the anchor element be given it's dimensions?
brendo
That would only work if the only thing inside the div were the anchor .. think about a cup full off water: if you put a grape inside of the cup, that grape will occupe a certain space inide the cup that can't be occuped at the same time by the water. Its pretty much the same in html / css
yoda
Sorry to be persistent, but I'm not quite sure why this example doesn't apply to the code I posted. The `a.grow` is inside the `div.column-header` and I want it to 'bubble up' over the `h2` and `img` elements. Because it has no `background` set, ie. transparent, the other elements can be seen, but the `a.grow` should be the only thing that has focus when the mouse is over.What part of my reasoning is flawed?
brendo
The problem is that all the elements that you have inside that div are at the same "level". If you really want to put only one anchor element to "catch" all the div elements, you must use javascript, but that sollution has so much "complications" and "issues" that most of the programmers don't use it. Anyway, if that div has fixed position (relative to top and left of the browser), I can give you the code to make ir possible.
yoda
Yes I'd like that code, if for nothing then to learn more :)
brendo
#anchor_over_div {position:absolute;top:100px;left:100px;} - just switch the top and left attributes to the absolute margin from the top and left of the browser into the anchor, and apply also the width and height of the div into that anchor.
yoda