[英]Anchor link click-able area using css - IE issue
I have a menu as follows, I need to enable entire anchor area to be clickable, unfortunately it seems to none. 我有一个菜单,如下所示,我需要使整个锚区域都可单击,但不幸的是似乎没有。
HTML 的HTML
<div><a href='#'>Home</a></div>
<div><a href='#'>Contact us</a></div>
<div><a href='#'>Feedback</a></div>
<div><a href='#'>Products</a></div>
CSS 的CSS
div {height:40px; padding-top:5px; border:#999 solid 1px; margin-bottom:5px;}
a{color:#FFF; font-size:15px;text-shadow: -1px -2px 2px #212121; filter: dropshadow(color=#212121, offx=-1, offy=-2); padding: 13px 0 0 16px; display:block; height:25px; width:100%; zoom:1; line-height: 30px; }
Fiddle as http://jsfiddle.net/3Hyty/2/ 小提琴作为http://jsfiddle.net/3Hyty/2/
Updated: Problem really in IE 更新:IE中确实存在问题
Your CSS is fine, the issue is the jsfiddle blocks link clicks by default unless they open in a new tab. 您的CSS很好,问题是jsfiddle会默认阻止链接点击,除非它们在新标签页中打开。 Make the links have
使链接有
target='_blank'
and they work in jsfiddle as shown here: http://jsfiddle.net/V3qML/1/ . 并且它们在jsfiddle中工作,如下所示: http : //jsfiddle.net/V3qML/1/ 。
Obviously for your production environment just use your code as is :) 显然,对于您的生产环境,只需按原样使用代码即可:)
Add an onClick to the div and style the div to use cursor:hand or cursor:pointer depending on browser see How can I make the cursor a hand when a user hovers over a list item? 将div添加到onClick并设置div的样式,以根据浏览器使用cursor:hand或cursor:pointer来查看用户将鼠标悬停在列表项上时如何使光标成为手形?
Applied to your jsFiddle: http://jsfiddle.net/3Hyty/5/ 应用于您的jsFiddle: http : //jsfiddle.net/3Hyty/5/
The operative line being: 操作线是:
<div onClick="javascript:document.location.href='#';" style="cursor:hand;cursor: pointer;">Feedback</div>
HTML5 allows for block elements inside anchors, which forces the anchor to the dimensions of the block element inside it. HTML5在锚点内允许使用块元素,这会将锚点强制为其内部的块元素的尺寸。 Alternatively, use spans and style them inline-block or block:
或者,使用跨度并以内联块或块样式设置它们的样式:
<a href='#'><div>Home</div></a>
or: 要么:
<a href='#'><span class="block">Home</span></a>
<style>
span.block {display: block;}
</style>
a{
margin:0 10px;
display:block;
float:left;
width:100%;
color:#F00;
font-size:15px;
text-shadow: -1px -2px 2px #212121; padding: 0 0;
height:25px;
zoom:1;
line-height: 30px;
}
It was able to do with float left 能够向左浮动
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.