简体   繁体   English

忽略悬停对象

[英]Ignore objects over hover

I have a background-image with transform scale and rotate. 我有一个带有变换比例和旋转的背景图像。 So whenever you have your cursor over it it will rotate 15deg and scale 2. 因此,只要将光标移到它上面,它就会旋转15度并缩放2。

I want to place my logo over it but how can I do it so whenever I have my cursor over the logo it will still counts as I am hovering at the background? 我想将徽标放置在徽标上,但是当我将光标悬停在徽标上时,该徽标仍然会随着我在背景上徘徊而保持计数? CSS: CSS:

.background-image:hover {
  position: fixed;
  right: 0px;
  right: 0px;
  z-index: -999;
  display: block;
  background-image: url("whatever.jpg");
  width: 100%;
  height: 100%;

  -webkit-filter: blur(8px);
  -moz-filter: blur(8px);
  -o-filter: blur(8px);
  -ms-filter: blur(8px);
  filter: blur(8px);

  transform: rotate(12deg) scale(2);
  -o-transform: rotate(12deg) scale(2);
  -moz-transform: rotate(12deg) scale(2);
  -webkit-transform: rotate(12deg) scale(2);

  transition: all 0.3s ease-in-out 0s;
}

Here I have a div over the background, if I hold my cursor over the div the hover for the background doesn't count anymore and it goes back. 在这里,我在背景上有一个div,如果我将鼠标悬停在div上,背景的悬停将不再计数,它会返回。 How can I make the div still visible and when I hover my mouse over the div the background will go back? 如何使div仍然可见,当我将鼠标悬停在div上时,背景会返回吗? CSS for the div: div的CSS:

<div class="logo-position"></div>

.logo-position {
  position: relative;
  width: 800px;
  height: 600px;
  padding: 0;
  margin-right: auto;
  margin-left: auto;
  background-color: white;
  top: 80px;
}

The "hitbox" for the div is also very weird. div的“ hitbox”也很奇怪。 I can take the cursor to the right of the div and it still counts as I have my cursor inside the div as the background transform goes back. 我可以将光标移到div的右边,当背景转换返回时,它仍然会计数为光标位于div内。 Anybody see anything I have done wrong? 有人看到我做错了什么吗?

Add pointer-events: none; 添加pointer-events: none; to the .logo-position class. .logo-position类。 This should cause the logo to ignore the hover event and let it pass through. 这将导致徽标忽略悬停事件并使其通过。 Note that it will ignore all events, so it won't be clickable either. 请注意,它将忽略所有事件,因此也将无法单击。

如果.logo-position div是.background-image div的子级,它将允许将鼠标悬停应用于徽标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM