|
|
|||||
Making DIV a Link - Javascript Vs CSSFew days ago, I was looking for the best way to make a DIV into a link when I came across this website: Almost Effortless!. The author showed how to make a div a link with a little bit of Javascript (see article). It is actually pretty simple: The Javascript Technic: 1. <div id="header" onclick="location.href='http://www.example.com';" style="cursor:pointer;"> </div> <div id="header" onclick="location.href='http://www.example.com';" style="cursor:pointer;"> </div> By this method, the whole block is clickable with just a single line of code while, with CSS, you will need to set few parameters to get the same result. Pretty cool, no? Here is the CSS technic: Now, let’s see how it works with CSS. First, put a link inside your div: 1. <div id="header"><a href="#"></a></div> <div id="header"><a href="#"></a></div> …and now set the link’s display property to 100% to fill the DIV in your stylesheet: 1. #header { #header { #header a { #header a:hover { Conclusion: source: web-kreation |
|||||
| Copyrights Reserved AjaxProjects.com 2006-2013, Powered by Enozom - Mobile Development Company -Privacy Policy |