我有一个 width=160px
,height=80px
的 div。由于某种原因,div 有一个 margin-left=540px
。此外,在 CSS 中,我设置了 cursor:pointer
。
问题是,当我将光标移动到 div 的左侧,即边距区域时,鼠标变为指针。
如何让光标移动到margin区域不变,移动到div上才改变?
我需要使用 margin,因为使用 position 会导致一些结构错误。
最佳答案
你可以用 css :after
pseudo
元素来实现这个吗:
div {
width: 100px;
height: 100px;
background: red;
margin-left: 100px;
cursor: pointer;
position: relative;
}
div:after {
content: '';
position: absolute;
height: 100%;
top: 0;
left: -100px;
width: 100px;
}
<div></div>
原始 fiddle :http://jsfiddle.net/EwLVu/
关于html - 如何使光标在CSS的边距区域保持不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8238069/