上的 tabIndex 上有奇怪的边框元素
我目前正在尝试使一些显示/隐藏内容在大型网站(超过 30,000 个页面)上更易于访问,并且在添加 tabindex 时遇到了一个奇怪的错误,其中单击控件打开隐藏内容。
设置 p 标签,单击该标签即可淡入 div 显示隐藏内容。 我根本无法修改 HTML,因为网站上有数千个 HTML,所以这就是我必须处理的内容。目前,为了添加 tabindex,我正在使用 jQuery 动态执行此操作,为每个 p 标记添加不断增加的选项卡索引。
为了摆脱这个奇怪的边框,我首先尝试的是 CSS:
#content div.showHide p.showHideTitle:focus,
#content div.showHide p.showHideTitle::focus,
#content div.showHide p.showHideTitle::-moz-focus-border {
outline: 0px !important; border: 0px !important;
}
这在 Chrome 和 Safari 中有效,但在 IE8 和 Firefox 3.6 中,当我单击 p 标签时,我仍然会看到边框。关于如何摆脱它有什么建议吗?
I'm currently trying to make some show/hide content more accessible on a large site (in excess of 30,000 pages) and I've come across a weird bug when adding tabindex where a dotted border appears when clicking on the control to open the hidden content.
The set up with p tag which you click to fadeIn a div which shows the hidden content. I can't modify the HTML at all due to there being thousands of these across the site so this is what I have to work with. At the moment to add tabindex i'm doing it dynamically with jQuery, adding an ever increasing tab index to each p tag.
My first though to get rid of this weird border was to try CSS:
#content div.showHide p.showHideTitle:focus,
#content div.showHide p.showHideTitle::focus,
#content div.showHide p.showHideTitle::-moz-focus-border {
outline: 0px !important; border: 0px !important;
}
This works in Chrome and Safari but in IE8 and Firefox 3.6 I still get the border when I click on the p tag. Any suggestions for how to get rid of it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是关于:
您正在为伪类
:focus
设置大纲样式,但这可能“太晚了”。这是一个简单的 jsFiddle
whats about:
You are setting the outline style for the pseudo class
:focus
but this may be "to late".Here a simple jsFiddle
我有一个更好的解决方案来解决这个问题,混合javascript/css。
这样,如果您按 Tab 键浏览,它仍然有效,但如果单击则无效。
I have a better solution to this issue, hybrid javascript/css.
This way it still works if you tab through, but not if you click.
尽管不是最有效的 CSS 选择器,但您可以从所有具有 tabindex 属性的 DOM 元素中删除它,只需使用以下 CSS:
Although not the most efficient CSS selector by any means you can remove this from all DOM elements with tabindex attributes just the following CSS:
您是否尝试过使用脚本设置
css
?像这样的东西Have you tried setting the
css
with your script? Something like但是,用户通过按 Tab 键聚焦时应该看到轮廓。
But, the user should see the outline when focused by tab press.