css - 将 div 链接到外部 url

标签 css html hyperlink

我希望我的 div 可以点击并链接到外部 url。为什么这不起作用或者我应该怎么做?

html:

 <div id="logo_left">
   <a href="..external url.."></a>
 </div>

样式表:

#logo_left {
  //stylestuff
}
#logo_left a {
  display: block;
  height: 100%;
  width:  100%;
}

最佳答案

你应该只拿 <a>并将其变成 display: block;

a.block { display: block; height: 100px; width: 100px; }

Working Example


或者,如果您使用 <!doctype html> ,您可以将 div 包装在 <a> 中并以这种方式使其可点击。

Working Example

关于css - 将 div 链接到外部 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7152021/

相关文章:

css - 在 tableView javafx 中更改 css 行

html - 修复了剪辑路径 css/html 中的图像

javascript - 从 Javascript 访问 SVG 对象时收到 Uncaught SecurityError

html - Outlook 忽略了我电子邮件的 CSS,包括字体系列和背景颜色

javascript - 如何动态改变元素?

iOS >> 广告转化链接 : Is there a way to "catch" from which site/banner/ad users got to my app in the App Store?

css - 在 CSS :before 中添加图标链接

css - 将 JQuery Mobile 下拉值资本化

单击链接时的 JavaScript 弹出警报

javascript - 加载窗口上的 jQuery