Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
Mouse curser follow parallax effect on an image

I want these images to display when hovering over the title in addition to that when I hover and move my cursor around the title I want the image to follow the cursor. I am new to JavaScript, any help from you guys would be much appreciated.

.container {
  display: inline-block;
}

.manImg {
  display: none;
}

.manImg2 {
  display: none;
}

.hover-text {
  color: black;
  text-align: center;
  font-size: 50px;
  letter-spacing: 5px;
  line-height: 3px;
  font-family: Odachi;
}

.hover-text:hover {
  color: red;
}

.hover-text:hover~.manImg2 {
  display: block;
  top: 0px;
  left: 0px;
  right: 0px;
  height: 100%;
  width: 100%;
  background: url(https://awallpaperaday.com/wp-content/uploads/2019/03/orange-cliffs-1920x1080-1860x1046.jpg) center;
  background-size: cover;
  position: fixed;
  z-index: -9999999999;
}

.hover-text:hover~.manImg {
  display: block;
  top: 0px;
  left: 0px;
  right: 0px;
  height: 100%;
  width: 100%;
  background: url(https://th.bing.com/th/id/R.1084082127f8d9d45194657db272109e?rik=6tKaSe%2b57Mvvkg&riu=http%3a%2f%2fimages.freehdw.com%2f510%2f3d-abstract_widewallpaper_fulfill-wish_50806.jpg&ehk=Tlkf5BUKl0223C4FgHOuHAHIe5tedec%2bWhkhyj5tHyI%3d&risl=&pid=ImgRaw&r=0) center;
  background-size: cover;
  position: fixed;
  z-index: -9999999999;
}
<div class="module-jamf" id="module-jamf">

  <a class="jamf-container" id="jamf-container" target="_blank" rel="noopener">
    <center>
      <p class="hover-text">TITLE1</p>
      <img id="new" class="manImg" src="">
      <div class="jamf-mover" id="jamf-mover">
      </div>
  </a>
</div>

<div class="module-jamf" id="module-jamf">

  <a class="jamf-container" id="jamf-container" target="_blank" rel="noopener">
    <center>
      <p class="hover-text">TITLE2</p>
      <img id="new" class="manImg2" src="">
      <div class="jamf-mover" id="jamf-mover">
      </div>
  </a>
</div>

I want these images to display when hovering over the title in addition to that when I hover and move my cursor around the title I want the image to follow the cursor. I am new to JavaScript, any help from you guys would be much appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I suggest you bind to the mousemove event on the document and then use that to track the mouse x and y position, then translate that value to the background position of said images, just add the below javascript to your page (at the end of the document in script tag after the jquery js library import)

Code

I'm using the latest version of jQuery

$(document).on('mousemove', (e)=>{
    let el = $('.manImg'); 
    el.css({"background-position": (el.width() + e.offsetX) + "px " + (el.height() + e.offsetY) +  "px"});
    let el2 = $('.manImg2'); 
    el2.css({"background-position": (el2.width() + e.offsetX) + "px " + (el2.height() + e.offsetY) +  "px"});
});

Example

Here is a jsFiddle Example

Edit 1

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda