2017-07-28 15 views
-1

我需要在包装div id = a上使用cursor:pointer;,但当用户将光标移动到A或B上时,光标将设置为默认值。无法在容器div上应用光标指针

我需要,而不是强制cursor:pointer;包装的div内的所有元素应用,因此A和B.

我曾尝试使用z索引,但没有成功。

任何解决方法? (如果可能,我需要一个CSS解决方案) 非常感谢。

<div id="a" style="width:200px; height:200px; background-color:yellow; cursor:pointer; z-index: 100;"> 
 
A 
 
    <div id="b" style="width:50px; height:50px; background-color:blue; cursor:auto;"> 
 
    B 
 
    </div> 
 
    <div id="c" style="width:50px; height:50px; background-color:orange; cursor:auto;"> 
 
    C 
 
    </div> 
 
</div>

回答

6

使用inherit而不是auto

<div id="a" style="width:200px; height:200px; background-color:yellow; cursor:pointer; z-index: 100;"> 
 
A 
 
    <div id="b" style="width:50px; height:50px; background-color:blue; cursor:inherit"> 
 
    B 
 
    </div> 
 
    <div id="c" style="width:50px; height:50px; background-color:orange; cursor:inherit;"> 
 
    C 
 
    </div> 
 
</div>

1

保持简单。与cursor:pointer更换cursor:auto

<div id="a" style="width:200px; height:200px; background-color:yellow; cursor:pointer; z-index: 100;"> 
 
A 
 
    <div id="b" style="width:50px; height:50px; background-color:blue; cursor:pointer;"> 
 
    B 
 
    </div> 
 
    <div id="c" style="width:50px; height:50px; background-color:orange; cursor:pointer;"> 
 
    C 
 
    </div> 
 
</div>

0

您需要使用cursor: pointer;的ID bc,而不是cursor: auto;

0

这将使cursor: pointer所有<div>的内线id="a"

<div id="a" style="width:200px; height:200px; background-color:yellow; cursor:pointer; z-index: 100;"> 
 
A 
 
    <div id="b" style="width:50px; height:50px; background-color:blue;"> 
 
    B 
 
    </div> 
 
    <div id="c" style="width:50px; height:50px; background-color:orange;"> 
 
    C 
 
    </div> 
 
</div>

1

使用inherit而不是auto

<div id="a" style="width:200px; height:200px; background-color:yellow; cursor:pointer; z-index: 100;"> 
A 
    <div id="b" style="width:50px; height:50px; background-color:blue; cursor:inherit"> 
    B 
    </div> 
    <div id="c" style="width:50px; height:50px; background-color:orange; cursor:inherit;"> 
    C 
    </div> 
</div>