tags:

views:

218

answers:

5

Hello, I have:

 <div class="sliderPart">                                                                  
    <a href="#computers">
       <strong>Some text</strong>
    </a>
 </div>

.sliderPart {   
    width: 25%;
    height: 100%;
}

.sliderPart a {
    display:block;
    position:relative;
    text-decoration:none;
    height: 100%;
    font: 1.3em  Arial, Sans-serif;
}

How can I make my link clickable for all div-area?

A: 

Put the link outside the div. You can make an anchor tag act similarly to a div. Like you're doing in the css you posted.

Ólafur Waage
+2  A: 

The easiest thing is to remove the div altogether:

<a href="#computers" class="sliderPart">
   <strong>Some text</strong>
</a>

a.sliderPart {
  ...
}
Kobi
A: 

For dropdown lists, I use the following method a lot...

If you're not opposed to using scripts, you can make the div itself a proxy of sorts, so that if you click anywhere on the div, the first link within that div is subsequently clicked automatically.

$(".sliderPart").bind("click", function(){
  $("a:first", this).trigger("click");
});

Of course you would want to update your styles for the div when you mouse over it to indicate the entire thing is clickable.

Jonathan Sampson
It doesn't work for me (I'm using JQuery too).
Ockonal
+1  A: 

Try this:

$(".trigger").click(function() {
    window.location = $(this).find("a").attr("href");
    return false;
});

..you'd also need to give cursor: pointer to the clickable element.

Nimbuz
A: 

Great, that was exactly what I was looking for as well!

BeeGee_Tokyo