Link div to external url
I want my div to be clickable and link to an external url. Why doesn't this work or what should I do instead?
html:
<div id="logo_left">
<a href="..external url.."></a>
</div>
Stylesheet:开发者_开发技巧
#logo_left {
//stylestuff
}
#logo_left a {
display: block;
height: 100%;
width: 100%;
}
You should take only the <a>
and make it into a display: block;
a.block { display: block; height: 100px; width: 100px; }
Working Example
Alternatively, if you are using <!doctype html>
, you could wrap the div inside an <a>
and have it clickable that way.
Working Example
You need to add an event on the on click property of div
<
div id="logo_left" onclick="window.redirect=..external url..">
</div>
You don't need JavaScript to link to a specific URL just use the complete address starting from http:
<div id="logo_left">
<a href="http://www.external-url.com"></a>
</div>
精彩评论