html - 为什么标记中跨度的 dom TreeView 损坏?

标签 html css dom treeview

HTML

<div class="wrapper">
    <a href="#">
        Link-1
        <span class="sub-list hidden">
            <a href="#">SubLink-1</a>
            <a href="#">SubLink-2</a>
            <a href="#">SubLink-3</a>
        </span>
    </a>
    <a href="#">Link-2</a>
    <a href="#">Link-3</a>
</div>

CSS

.wrapper {
    border-bottom: 1px solid #dfdfdf;
    padding-bottom: 5px;
    padding-right: 50px;
    height: 25px;
}

.wrapper > a {
    font-size: 13px;
    font-weight: bold;
    padding: 5px 6px;
    border: 1px solid #ffffff;
    border-bottom: none;
    float: right;
    display: block;
}


.sub-list {
    background-color:#ffffff;
    width: 251px;
    height: 40px;
    border-right: 1px solid #dfdfdf;
    border-left: 1px solid #dfdfdf;
    border-bottom: 1px solid #dfdfdf;
    padding: 10px 10px 0 0;
    text-align: right;
}

http://jsfiddle.net/6vAQF/1/

我想创建一个菜单和子菜单。但是,当我将子菜单放在带有跨度包装器的 a 标签下时,dom treeview 显示为已损坏,如下图所示; enter image description here

这是为什么?

最佳答案

您在链接中嵌套链接,这是被禁止的:

Links and anchors defined by the A element must not be nested; an A element must not contain any other A elements.

http://www.w3.org/TR/html401/struct/links.html#h-12.2.2

Creating anchor tag inside anchor tag

关于html - 为什么标记中跨度的 dom TreeView 损坏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24550017/

相关文章:

javascript - 当我尝试从网站的其他页面访问网页时,如何从缓存中获取网页并恢复表单中的数据?

javascript - 长时间运行函数的 DOM 刷新

html - 如何使用 bootstrap4 修复开关按钮?

css - 网格元素 100% 父级高度

html - <strong> 与字体粗细 :bold & <em> vs. 字体样式:斜体

javascript - 引用错误 : function is not defined

javascript - jQuery:如何仅在 div 展开后淡入导航?

php - 如何使用 CURL 从页面解析实际的 HTML?

html - Chrome 中的文件 URL 跨域问题 - 意外

jquery - 如何根据显示使 div 垂直响应