首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >突出显示列表条目:伪元素之前(z-索引问题)

突出显示列表条目:伪元素之前(z-索引问题)
EN

Stack Overflow用户
提问于 2013-05-28 10:50:36
回答 1查看 1.4K关注 0票数 3

我有一个项目列表(由JSTree生成)。我想通过一个不同的HTML结构中已经对我起作用的伪元素突出显示项目的整行。现在,对于生成的元素,z-索引被搞乱了。项目的z-索引现在是-1。如果我将它更改为1,它将出现在所有链接的前面,但应该是背景。无论我选择什么值,我都不能让高亮显示在背景前面,而是显示在链接后面。

下面是html代码的一部分:

代码语言:javascript
复制
<div id="jlayout_west_center" class="center" style="width: 300px; height: 897px; left: 0px; top: 0px; position: absolute;">
    <div id="jlayout_west_center_content" class="jlayout-panelContent jstree jstree-0 jstree-custom jstree-focused" style="width: 100%; height: 100%;">
        <ul class="jstree-no-dots jstree-no-icons">
            <li class="jstree-last jstree-open"><ins class="jstree-icon jstree-ocl">&nbsp;</ins><a href="javascript:void(0);"><ins class="jstree-icon jstree-themeicon">&nbsp;</ins>Root</a>

                <ul style="">
                    <li class="jstree-open"><ins class="jstree-icon jstree-ocl">&nbsp;</ins><a href="javascript:void(0);" class=""><ins class="jstree-icon jstree-themeicon">&nbsp;</ins>Category1</a>

                        <ul style="">
                            <li class="jstree-leaf"><ins class="jstree-icon jstree-ocl">&nbsp;</ins><a href="javascript:void(0);"><ins class="jstree-icon jstree-themeicon">&nbsp;</ins>Item 1</a>

                            </li>
                            [...]
                        </ul>
                    </li>
                    <li class="jstree-last jstree-closed"><ins class="jstree-icon jstree-ocl">&nbsp;</ins><a href="javascript:void(0);" class=""><ins class="jstree-icon jstree-themeicon">&nbsp;</ins>Category 2</a>

                    </li>
                </ul>
            </li>
        </ul>
    </div>
</div>

css是这样组成的:

代码语言:javascript
复制
 /*
 * jsTree default theme 1.0
 * Supported features: dots/no-dots, icons/no-icons, focused, loading
 * Supported plugins: ui (hovered, clicked), checkbox, contextmenu, search
 */
 .jstree-custom {
    background: #383838;
}
.jstree-custom a {
    color: #c3c3c3;
    font-size: 14px;
    line-height: 30px;
    height: 30px;
}
.jstree-custom a.jstree-hovered {
    color: #ffffff;
    background: transparent;
    border-color: transparent;
}
.jstree-custom a.jstree-clicked {
    color: #ffffff;
    background: transparent;
    border-color: transparent;
}
.jstree-custom li:hover a.jstree-hovered:before {
    position:absolute;
    left: 0;
    content:"";
    width: 100%;
    height: 30px;
    background: #614832;
    z-index:-1;
}
.jstree-custom a.jstree-clicked:before {
    position:absolute;
    left: 0;
    content:"";
    width: 100%;
    height: 30px;
    background: #614832;
    z-index: -1;
}
.jstree-custom {
    padding-left: 20px;
    padding-top: 15px;
}
.jstree-custom ul:first-child {
    margin-top: 0px;
}
.jstree-custom li, .jstree-custom ins {
    /*background-image:url("../img/lib/jquery-plugins/jstree/d.png");*/
    background-repeat: no-repeat;
    background-color: transparent;
    font-size: 12px
}
.jstree-custom li {
    background-position:-90px 0;
    background-repeat:repeat-y;
}
.jstree-custom li.jstree-last {
    background:transparent;
}
.jstree-custom .jstree-ocl {
    width: 7px;
    height: 30px;
    margin-right: 13px;
}
.jstree-custom .jstree-open > .jstree-ocl {
    background-image:url(../img/lib/jquery-plugins/jstree/tree_opened.gif);
}
.jstree-custom .jstree-closed > .jstree-ocl {
    background-image:url(../img/lib/jquery-plugins/jstree/tree_closed.gif);
}
.jstree-custom .jstree-leaf > .jstree-ocl {
    background-position:-36px 0;
}
.jstree-custom .jstree-loading > .jstree-ocl {
    background:url("throbber.gif") center center no-repeat !important;
}
.jstree-custom .jstree-hovered {
    background:#e7f4f9;
    border:1px solid #d8f0fa;
    padding:0 2px 0 1px;
}
.jstree-custom .jstree-clicked {
    background:#beebff;
    border:1px solid #99defd;
    padding:0 2px 0 1px;
}
.jstree-custom a .jstree-themeicon {
    background-position:-56px -19px;
}
.jstree-custom .jstree-no-dots li, .jstree-custom .jstree-no-dots .jstree-leaf > .jstree-ocl {
    background:transparent;
}
.jstree-custom .jstree-no-dots .jstree-open > .jstree-ocl {
}
.jstree-custom .jstree-no-dots .jstree-closed > .jstree-ocl {
}
.jstree-custom .jstree-no-icons a .jstree-themeicon {
    display:none;
}
.jstree-custom .jstree-search {
    font-style:italic;
    color:aqua;
}
.jstree-custom .jstree-no-checkboxes .jstree-checkbox {
    display:none !important;
}
.jstree-custom .jstree-check {
    display:none;
}
.jstree-custom .jstree-checkbox {
    background-position:-2px -19px;
}
.jstree-custom .jstree-checked {
    background-position:-38px -19px;
}
.jstree-custom .jstree-undetermined {
    background-position:-20px -19px;
}
.jstree-custom a:hover .jstree-checkbox {
    background-position:-2px -37px;
}
.jstree-custom a:hover .jstree-checked {
    background-position:-38px -37px;
}
.jstree-custom a:hover .jstree-undetermined {
    background-position:-20px -37px;
}
#jstree-dnd.jstree-custom ins {
    background:transparent;
}
#jstree-dnd.jstree-custom .jstree-ok {
    background:url("d.png") -2px -53px no-repeat;
}
#jstree-dnd.jstree-custom .jstree-er {
    background:url("d.png") -18px -53px no-repeat;
}
/*#jstree-marker.jstree-custom { background:url("d.png") -41px -57px no-repeat !important; text-indent:-100px; }*/
 .jstree-custom .jstree-locked a {
    color:silver;
    cursor:default;
}
.jstree .jstree-icon.jstree-themeicon {
    display: none;
}

和一个JSFiddle,所有这些都放在一起,在这里问题可以重现:

http://jsfiddle.net/nt7eC/1/

请参阅项目2,它具有jstree单击类,并且应该以突出显示的背景显示。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-28 14:42:22

更新:修改为整行

您需要添加两行代码:

代码语言:javascript
复制
.jstree-custom {
    position: relative; /* add this */
    z-index: 1; /* add this */
}

Here's the fiddle example.

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16790179

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档