草庐IT

html - Chrome 中带有 HTML 选择的奇怪行为

coder 2023-08-04 原文

我有一个非常简单的 CSS 菜单,悬停时显示一个 UL 列表。很久以前,在 Chrome 中,当我选择与被 display: none 隐藏的菜单位于同一位置的选项时,我的菜单会悬停。

选择选项如何在点击时将鼠标悬停在隐藏的对象上?这只发生在 Chrome 上。

我试图将 select z-index 更改为更高的值。 将菜单的 z-index 更改为 -1,直到父级 ul 悬停,但没有成功,问题仍然存在

Here是代码

尝试选择选项 test5:

ul.menu ul {
    display: none !important;
}

ul.menu li:hover>ul {
    display: block !important;
}

ul.menu ul {
    position: absolute;
    left: -1px;
    top: 98%;
}

ul.menu ul ul {
    position: absolute;
    left: 98%;
    top: -2px;
}

ul.menu, ul.menu ul {
    margin: 0;
    list-style: none;
    padding: 2px;
}

ul.menu li ul.links {
    margin: 0;
    list-style: none;
    padding: 0;
    border-color: #AAAAAA;
    border-width: 1px;
    border-style: solid;
}

ul.menu ul.links li {
    margin: 0px;
    list-style: none;
    padding: 2px;
    background-color: #F5F5F5;
    background-repeat: repeat;
}

ul.menu table {
    border-collapse: collapse;
}

ul.menu {
    display: block;
    float: left;
}

ul.menu ul {
    width: 160.65px;
}

ul.menu li {
    display: block;
    margin: 0;
    font-size: 0px;
    margin-right: 4px;
}

ul.menu a:active, ul.menu a:focus {
    outline-style: none;
}

ul.menu a, ul.menu li.dis a:hover, ul.menu li.sep a:hover {
    display: block;
    vertical-align: middle;
    border-width: 0px;
    border-color: #6655ff;
    border-style: solid;
    text-align: left;
    text-decoration: none;
    padding: 3px;
    font-family: Arial, Helvetica, Verdana;
    font-size: 11px;
    color: #000;
    text-decoration: none;
    cursor: default;
    border: 1px solid transparent;
}

ul.menu ul.links a {
    display: block;
    vertical-align: middle;
    background-color: #F5F5F5;
    border-width: 0px;
    border-color: #6655ff;
    border-style: solid;
    text-align: left;
    text-decoration: none;
    padding: 4px;
    font: normal 11px Verdana;
    color: black;
    text-decoration: none;
    cursor: default;
    border: 1px solid transparent;
}

ul.menu span {
    display: none;
    overflow: hidden;
}

ul.menu li {
    display: block;
    float: left;
}

ul.menu ul li {
    float: none;
}

ul.menu ul a {
    text-align: left;
    white-space: nowrap;
}

ul.menu li.sep {
    text-align: center;
    padding: 0px;
    line-height: 0;
    height: 100%;
}

ul.menu li.sep span {
    float: none;
    padding-right: 0;
    width: 5px;
    height: 16px;
    display: inline-block;
    background-color: #AAAAAA;
    background-image: none;
}

ul.menu ul li.sep span {
    width: 80%;
    height: 3px;
}

ul.menu li:hover {
    position: relative;
    z-index: 999999;
}

ul.menu li:hover>a {
    text-decoration: none;
    border: 1px inset #CCCCCC;
    background: #E3E3E3;
    border-radius: 3px;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
}

ul.menu li a:hover {
    position: relative;
    text-decoration: none;
    border: 1px inset #CCCCCC;
    background: #E3E3E3;
    border-radius: 3px;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
}

ul.menu ul.links li:hover>a {
    background: #F8FBFE;
    text-decoration: none;
    border-radius: 1px;
    -webkit-border-radius: 1px;
    -moz-border-radius: 1px;
    border: 1px solid #BAE3FE;
}

ul.menu ul.links li a:hover {
    background: #F8FBFE;
    position: relative;
    text-decoration: none;
    border-radius: 1px;
    -webkit-border-radius: 1px;
    -moz-border-radius: 1px;
    border: 1px solid #BAE3FE;
}

ul.menu li.dis a {
    color: #AAAAAA !important;
}

ul.menu img {
    border: none;
    float: left;
    _float: none;
    margin-right: 4px;
    width: 16px;
    height: 16px;
}

ul.menu ul img {
    width: 16px;
    height: 16px;
}

ul.menu img.over {
    display: none;
}

ul.menu li.dis a:hover img.over {
    display: none !important;
}

ul.menu li.dis a:hover img.def {
    display: inline !important;
}

ul.menu li:hover > a img.def {
    display: none;
}

ul.menu li:hover > a img.over {
    display: inline;
}

ul.menu a:hover img.over,ul.menu a:hover ul img.def,ul.menu a:hover a:hover ul img.def,ul.menu a:hover a:hover a:hover ul img.def,ul.menu a:hover a:hover img.over,ul.menu a:hover a:hover a:hover img.over,ul.menu a:hover a:hover a:hover a:hover img.over {
    display: inline;
}

ul.menu a:hover img.def,ul.menu a:hover ul img.over,ul.menu a:hover a:hover ul img.over,ul.menu a:hover a:hover a:hover ul img.over,ul.menu a:hover a:hover img.def,ul.menu a:hover a:hover a:hover img.def,ul.menu a:hover a:hover a:hover a:hover img.def {
    display: none;
}

ul.menu a:hover ul,ul.menu a:hover a:hover ul,ul.menu a:hover a:hover a:hover ul {
    display: block;
}

ul.menu a:hover ul ul,ul.menu a:hover a:hover ul ul {
    display: none;
}

ul.menu span {
    display: block;
    background-position: right center;
    background-repeat: no-repeat;
    padding: 0 2px 0;
}

ul.menu ul.links span {
    background-image: url(./images/arr_nav.gif);
}

ul.menu ul.links a:hover span,ul.menu table a:hover a:hover span,ul.menu table a:hover a:hover a:hover span {
    background-image: url(./images/arr_nav.gif);
}

/* DHTML WINDOW */
.dhtmlwindow {
    position: absolute;
    border: 1px solid rgb(153, 153, 153);
    #border-color: rgb(142, 153, 186);
    #border-color: rgba(142, 153, 186, 0.3);
    visibility: hidden;
    background-color: #fff;
}

最佳答案

这似乎只是 Chrome 中的一个错误,我无法在 FF 中复制。

尝试添加这两行,当我在你的 fiddle 中试用它们时它们起作用了。

ul.menu li {pointer-events: none;}
ul.menu:hover li {pointer-events: auto;}

关于html - Chrome 中带有 HTML 选择的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23477546/

有关html - Chrome 中带有 HTML 选择的奇怪行为的更多相关文章

  1. ruby - 使用 ruby​​ 将 HTML 转换为纯文本并维护结构/格式 - 2

    我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h

  2. ruby-on-rails - Rails HTML 请求渲染 JSON - 2

    在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这

  3. ruby-on-rails - 使用 Sublime Text 3 突出显示 HTML 背景语法中的 ERB? - 2

    所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择

  4. ruby - 如何根据特征实现 FactoryGirl 的条件行为 - 2

    我有一个用户工厂。我希望默认情况下确认用户。但是鉴于unconfirmed特征,我不希望它们被确认。虽然我有一个基于实现细节而不是抽象的工作实现,但我想知道如何正确地做到这一点。factory:userdoafter(:create)do|user,evaluator|#unwantedimplementationdetailshereunlessFactoryGirl.factories[:user].defined_traits.map(&:name).include?(:unconfirmed)user.confirm!endendtrait:unconfirmeddoenden

  5. ruby-on-rails - Ruby url 到 html 链接转换 - 2

    我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.

  6. ruby - Rails 3 的 RGB 颜色选择器 - 2

    状态:我正在构建一个应用程序,其中需要一个可供用户选择颜色的字段,该字段将包含RGB颜色代码字符串。我已经测试了一个看起来很漂亮但效果不佳的。它是“挑剔的颜色”,并托管在此存储库中:https://github.com/Astorsoft/picky-color.在这里我打开一个关于它的一些问题的问题。问题:请建议我在Rails3应用程序中使用一些颜色选择器。 最佳答案 也许页面上的列表jQueryUIDevelopment:ColorPicker为您提供开箱即用的产品。原因是jQuery现在包含在Rails3应用程序中,因此使用基

  7. ruby-on-rails - capybara ::ElementNotFound:无法找到 xpath "/html" - 2

    我正在学习http://ruby.railstutorial.org/chapters/static-pages上的RubyonRails教程并遇到以下错误StaticPagesHomepageshouldhavethecontent'SampleApp'Failure/Error:page.shouldhave_content('SampleApp')Capybara::ElementNotFound:Unabletofindxpath"/html"#(eval):2:in`text'#./spec/requests/static_pages_spec.rb:7:in`(root)'

  8. ruby - 如何使用 Ruby 将 CSV 文件读入 HTML 表格? - 2

    我正在尝试将一个简单的CSV文件读入HTML表格以在浏览器中显示,但我遇到了麻烦。这就是我正在尝试的:Controller:defshow@csv=CSV.open("file.csv",:headers=>true)end查看:输出:NameStartDateEndDateQuantityPostalCode基本上我只获取标题,而不会读取和呈现CSV正文。 最佳答案 这最终成为最终解决方案:Controller:defshow#OpenaCSVfile,andthenreaditintoaCSV::Tableobjectforda

  9. ruby - Ruby gsub 替换中的行为不一致? - 2

    两个gsub产生不同的结果。谁能解释一下为什么?代码也可在https://gist.github.com/franklsf95/6c0f8938f28706b5644d获得.ver=9999str="\tCFBundleDevelopmentRegion\n\ten\n\tCFBundleVersion\n\t0.1.190\n\tAppID\n\t000000000000000"putsstr.gsub/(CFBundleVersion\n\t.*\.).*()/,"#{$1}#{ver}#{$2}"puts'--------'putsstr.gsub/(CFBundleVersio

  10. ruby-on-rails - Ruby 中意外的大小写行为 - 2

    我在一段非常简单的代码(如我所想)中得到了一个错误的值:org=4caseorgwhenorg=4val='H'endputsval=>nil请不要生气,我希望我错过了一些非常明显的东西,但我真的想不通。谢谢。 最佳答案 这是典型的Ruby错误。case有两种被调用的方法,一种是你传递一个东西作为分支的基础,另一种是你不传递的东西。如果您确实在case中指定了一个表达式语句然后评估所有其他条件并与===进行比较.在这种情况下org评估为false和org===false显然不是真的。所有其他情况也是如此,它们要么是真的,要么是假的。

随机推荐