Make a div into a link

后端 未结 27 1658
栀梦
栀梦 2020-11-22 03:15

I have a

block with some fancy visual content that I don\'t want to change. I want to make it a clickable link.

I\'m looking for something l

27条回答
  •  别跟我提以往
    2020-11-22 04:07

    Actually you need to include the JavaScript code at the moment, check this tutorial to do so.

    but there is a tricky way to achieve this using a CSS code you must nest an anchor tag inside your div tag and you must apply this property to it,

    display:block;
    

    when you've done that,it will make the whole width area clickable (but within the height of the anchor tag),if you want to cover the whole div area you must set the height of the anchor tag exactly to the height of the div tag,for example:

    height:60px;
    

    this is gonna make the whole area clickable,then you can apply text-indent:-9999px to anchor tag to achieve the goal.

    this is really tricky and simple and it's just created using CSS code.

    here is an example: http://jsfiddle.net/hbirjand/RG8wW/

提交回复
热议问题