href悬停影响另一个href

时间:2015-05-18 10:32:20

标签: html css

我在容器中有两个元素。我希望当悬停时,第一个边框变为黄色,当悬停第二个时,第一个边框变为黄色。

这是我的代码:

input[type="checkbox"] {
    display: none;
}

input[type="checkbox"]+label {    
    background: url('images/delete.png') no-repeat;
    height:17px;
}

input[type="checkbox"]:checked + label {    
    background: url('images/delete.png') no-repeat;
    height:17px;
}

我做了一个例子http://jsfiddle.net/df5dwsq8/

我不知道为什么这不起作用。如果有人能帮助我,我会很感激。

1 个答案:

答案 0 :(得分:0)

<强> CSS:

.href1, .href2
    {
        display:block;
        width:100px;
        height:100px;
    }

.href1
    {
        background:red;
        border:2px solid #000;
        margin-bottom:30px;
    }

.href1:hover
    {
        border-color:yellow;
    }

.href2
    {
        background:blue;
        border:2px solid #000;
    }

.href2:hover 
    {
        border-color:yellow;
    }

这是你需要的:http://jsfiddle.net/jani11bolkvadze/df5dwsq8/1/ ??