1

I have problem in Visual Studio 2008 (ASP.net with C#).

I have div#apDiv13, now I want to make my div a hyperlink.

I set my div's background and now I want it to be a hyperlink on mouse over or go to some address in web on-click.

Screenshot

Buh Buh
  • 7,443
  • 1
  • 34
  • 61
Hamed Parvini
  • 21
  • 1
  • 8

2 Answers2

3

This is very bad idea but technically it's possible. What you need to do is display link as a block and set its size to 100% vertically and horizontally so it fills the container div.

Example (http://jsfiddle.net/snLwg/)

div {
    background: red;
    width: 300px;
    height: 300px;
}

div a {
    display: block;
    height: 100%;
    width: 100%;
}
Stan
  • 25,744
  • 53
  • 164
  • 242
  • thank you steve ! I need div to put a object like images and ... in it , so now I need to make div to hyperlink whenever I click on my div like image above – Hamed Parvini Jun 16 '13 at 10:50
  • @HamedParvini you cannot make div into link, only with javascript. you can only make link to act like div. post some code and we will see what can be done. – Stan Jun 16 '13 at 15:02
  • Dear steve , this is my project , please download it , My div is in Index.aspx file , please check the Sin in div , I want it to make hyperlink . http://uplod.ir/c90tgwhj29a1/YalaYal.rar.htm – Hamed Parvini Jun 16 '13 at 15:10
0

Simple way:

<a href="http://stackoverflow.com/">
    <div>Contents of your div</div>
</a>
nu everest
  • 9,589
  • 12
  • 71
  • 90