Title: Need help to hover different background images in wordpress HTML code
Tags: javascript;html;jquery;css;wordpress
Question: I want exactly like this website: https://www.petzl.com/INT/en
I have displayed background video, 3 texts, by hovering on them the images are changing + links to access them.
But by hovering the text, petzl.com website have activated different images on hover, sometimes different images are appearing on hover.
Can I achieve the different images by css or need to have js or anything? Also need to have span/div elements to appear in one line.
My website link: beta.edgerope.com
Please find code below:
Below is the code, I have added as HTML shortcode in the page and in the background video is displayed


```<style&gt;

.image{
   
  height: 800px;
  width: 100%;
  display: grid;
  place-content:center;
  justify-content:middle;
  color: white;
  font-size:30px;
  background-color: #;
  background-position: center;
  background-size: cover;
}

.training{
    display:inline-block;
  padding-top: 50px;
  padding-right: 1500px;
  padding-bottom: 50px;
  padding-left: 1px;
  
}
  
 
.image&gt;div {
  display: inline-block;
  width: 100px;
  
}

.image&gt;div img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
 z-index: 0;
 display: inline-block;
}

.image&gt;div span {
  position: relative;
  z-index: 1;
  cursor: pointer;
  display: inline-block;
}

.image&gt;div span:hover+img {
  opacity: 1;
  display: inline-block;
}


.div{
    dipslay
}
</style&gt;

<div class="image"&gt;
    
    <div class="services"&gt;
     <span class="services" onclick="window.location=''"&gt;Services</span&gt;
    <img src="https://www.petzl.com/sfc/servlet.shepherd/version/download/0686800000D6sSCAAZ"&gt; 
   
    </div&gt;
    
    
  <div class="Training"&gt;
      <span class="training" onclick="window.location='beta.edgerope.com/courses'"&gt;Training</span&gt;
    
    <img src="https://beta.edgerope.com/wp-content/uploads/2022/08/1-1-1536x864.jpg"&gt; </div&gt;
    
  <div class="shop"&gt;
     <span class="shop" onclick="window.location='beta.edgerope.com/shop'"&gt;Shop</span&gt;
    <img src="https://www.petzl.com/sfc/servlet.shepherd/version/download/0686800000D6sSCAAZ"&gt; </div&gt;
</div&gt;```



:



Here is another answer: There are many ways to acomplish this, and you should be able to do this with pure css and html.
I've made an example that uses css pseudo elements in order to display the correct image when hovering the sections/links. Also changed up to use a tags instead of using ```onclick=&quot;window.location&quot;``` as you did.
Here you can change/set the default image in the #hero selector
```<style&gt;
    /* Styling for the default hero */
    #hero {
        height: 800px;
        width: 100%;
        display: flex;
        color: black;
        background-color: #000;
    }

    /* Wrapper for all the sections */
    .hero-sections {
        width: 100%;
        height: 100%;
        position: relative; /* Allows to change the z-index, and */
        z-index: 1;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 2rem;
    }

    /* Container for the image */
    .hero-imag181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16after {
        content: &quot;&quot;;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: -1; /* Allows the image to appear behind the text */
        pointer-events: none; /* Prevent image to show when hovering the 181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16ter element*/
        background-image: var(
            --bg-url
        ); /* Uses the images set by the html (css variable) */
        opacity: 0; /* Hides the image when it's not active */
        transition: opacity 0.5s; /* Adds a fade transition to the opacity*/
    }

    /* Styles when the the user hovers or has focus on the buttons/links */
    .hero-image:is(:hover, :focus-within)181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16ter {
        opacity: 1; /* Change the opacity when the text is active/in hover */
    }

    /* Styles the buttons/links */
    .hero-cta {
        color: white;
        text-decoration: none;
        font-size: 2rem;
    }
</style&gt;

<div id=&quot;hero&quot;&gt;
    <div class=&quot;hero-sections&quot;&gt;
        <div
            class=&quot;services hero-image&quot;
            style=&quot;
                --bg-url: url(https://www.petzl.com/sfc/servlet.shepherd/version/download/0686800000D6sSCAAZ);
            &quot;
        &gt;
            <a class=&quot;hero-cta&quot; href=&quot;#&quot;&gt;Services</a&gt;
        </div&gt;

        <div
            class=&quot;training hero-image&quot;
            style=&quot;
                --bg-url: url(https://beta.edgerope.com/wp-content/uploads/2022/08/1-1-1536x864.jpg);
            &quot;
        &gt;
            <a class=&quot;hero-cta&quot; href=&quot;beta.edgerope.com/courses&quot;&gt;Training</a&gt;
        </div&gt;

        <div
            class=&quot;shop hero-image&quot;
            style=&quot;
                --bg-url: url(https://www.petzl.com/sfc/servlet.shepherd/version/download/0686800000D6sSCAAZ);
            &quot;
        &gt;
            <a class=&quot;hero-cta&quot; href=&quot;beta.edgerope.com/shop&quot;&gt;Shop</a&gt;
        </div&gt;
    </div&gt;
</div&gt;
```
If you would like to go more advanced here I would recommend implementing some javascript handling ```mouseenter``` and ```mouseleave```. As you said you used Wordpress you could also use the .hover() from jQuery.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2022:00:09/05/22', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><html><jquery><css><wordpress>', 'Title': 'Need help to hover different background images in wordpress HTML code', 'ViewCount': 32, 'id': 73611306, 'user_AboutMe': None, 'user_AccountId': 26217509.0, 'user_DisplayName': 'Samir Malik', 'user_Reputation': 25.0, 'user_Views': 7.0, 'user_id': 19895457.0}}