我有一个基于 CSS 和 JS 的自定义光标,我想将其悬停在某些元素上时展开。我知道特异性似乎是我的问题,但我不确定我到底做错了什么。据我了解,+应该选择与对象不共享相同父对象的:hover对象/*kinda laggy cursor control js */const cursor = document.querySelector('.cursor');document.addEventListener('mousemove', e => { cursor.setAttribute("style", "top: " + e.pageY + "px; left: " + e.pageX + "px;")})const cursor2 = document.querySelector('.cursor2');document.addEventListener('mousemove', e => { cursor2.setAttribute("style", "top: " + e.pageY + "px; left: " + e.pageX + "px;")}).cursor { width: 25px; height: 25px; position: absolute; border: 2px solid rgb(41, 41, 41); border-radius: 50%; transform: translate(-50%, -50%); transition: 50ms; transition-timing-function: ; mix-blend-mode: difference; z-index: 200; pointer-events: none;}.cursor2 { z-index: 200; transition: 10ms; width: 5px; height: 5px; border-radius: 50%; background-color: black; pointer-events: none; mix-blend-mode: difference; position: absolute; transition-timing-function: ;}.inner { font-family: 'Helvetica'; font-size: calc(2em + 8vw); font-weight: 700; -webkit-text-fill-color: rgba(0, 0, 0, 0); -webkit-text-stroke: 1px; -webkit-text-stroke-color: rgb(0, 0, 0); letter-spacing: -.6vw; line-height: calc(.7em + 1vw); animation: marquee 30s linear infinite; display: inline-block; user-select: none;}a { text-decoration: none; cursor: none;}a:hover+.cursor { transform: scale(1.5); !important transition-duration: 500ms;}<div class="inner"> <span class="switcher about use"><a href="html/about/about.html">about</a></span><br></div><!-- outer cursor div--><div class="cursor"></div><!-- inner cursor div--><div class="cursor2"></div>问题是为什么a:hover+.cursor{}根本不影响光标。任何帮助,将不胜感激。
1 回答
慕姐4208626
TA贡献1852条经验 获得超7个赞
如果他们是直系兄弟姐妹,您可以与 一起工作+。因此,将光标放在范围内,然后它就可以工作了:)
<div class="inner">
<span class="switcher about use"><a href="html/about/about.html">about</a>
<div class="cursor"></div>
</span><br>
</div>
- 1 回答
- 0 关注
- 80 浏览
添加回答
举报
0/150
提交
取消