How can i make image hover in navbar


and Simon Medina

I'm trying to learn how to do a hover on
an image in the navbar , my goal is to make the div image "pic-index" be affected by the hover on the "HOME" link on the navbar and have the div change to Another image hovers.
I really don't know what should I do.
Here is my HTML :

I've added a code snippet to the question so you can see what's in the current code

     
        
    
    body {
      margin: 0;
      padding: 0;
      background: white;
    }
    
    .nav ul {
      list-style: none;
      background-color: white;
      text-align: center;
      padding: 0;
      margin: 0;
    }
    
    .logo{
    position: absolute;
    float: right;
    margin-left: 1136px;
    margin-top:-3px;
    }
    
    .mainul {
      height: 145px;
    box-shadow: 1px 1px 1px #7e7e7ea6;
    }
    
    .mainul2{
        
      height: 145px;
      box-shadow: 5px 9px 29px -2px #0000005e;
    }
    
    .pic-index{
        
        position:absolute;margin-left:936px;margin-top:62px;
    }
    .nav li {
      font-family: Varela Round;
      font-size: 1.2em;
      line-height: 40px;
      text-align: left;
        padding-right:;
    }
    
    .nav a {
      font-size:15px;
      margin-top:50px;
      margin-left:20px;
      text-decoration: none;
      color: #5a5a5a;
      display: block;
      padding-left: 15px;
    
      transition: .3s background-color;
    }
    
    .nav a:hover {
     color:#57c0ea;
    }
    
    .nav a.active {
      
      color: #444;
      cursor: default;
    }
    
    /* Sub Menus */
    .nav li li {
      font-size: .8em;
    }
    
    /*******************************************
       Style menu for larger screens
    
       Using 650px (130px each * 5 items), but ems
       or other values could be used depending on other factors
    ********************************************/
    
    @media screen and (min-width: 650px) {
      .nav li {
        width: 130px;
        border-bottom: none;
        height: 50px;
        line-height: 50px;
        font-size: 1.4em;
        display: inline-block;
        margin-right: -4px;
      }
    
      .nav a {
        border-bottom: none;
      }
    
      .nav > ul > li {
        text-align: center;
      }
    
      .nav > ul > li > a {
        padding-left: 0;
      }
    
      /* Sub Menus */
      .nav li ul {
        position: absolute;
        display: none;
        width: inherit;
      }
    
      .nav li:hover ul {
        display: block;
      }
    
      .nav li ul li {
        display: block;
      }
    }
    <div class="nav"> <ul class="mainul"> <ul class="mainul2">
        <div class="logo"><img src="images/Logo-1.png"></div>
        <div class="pic-index"><img src="images/nav-home-normal.png"></div> <li class="contact"><a href="#">צור קשר</a> <ul>
    
    </ul> </li> <li class="services"><a href="#">שירותים</a> <ul> <li><a href="#">Tutorial #1@@</a></li> <li><a href="#">Tutorial #2</a></li> <li><a href="#">Tutorial #3</a></li> </ul> </li>
         <li class="about"><a href="#">אודות</a>
    
    </li> <li class="home"><a href="#">דף הבית</a></li>
        </ul> </ul> </div>

   

Calvin Nunes

Once you .homerun out .pic-index, you can only do it with some JS or jQuery, here's jQuery's solution. If it .pic-indexcame before .homethen you would only be able to use CSS, but that's not the case.

(I added an image just to show the effect, please run the snippet in FULLSCREEN for better visualization)

EDIT
Another thing, I made a small update in the css but keep or not decide (add the css to the img class). Also, you have to list some HTML structure errors, some uland listart and end right wrong

/* HOVER */
$(function() {

  $('.home').mouseenter(function() {
    $('.pic-index img').attr(
    'src', 'http://icons.iconarchive.com/icons/paomedia/small-n-flat/256/sign-check-icon.png'
    );
  });
  
  $('.home').mouseleave(function() {
    $('.pic-index img').attr(
    'src', 'http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/256/Actions-help-about-icon.png'
    );
  });
  
});
body {
      margin: 0;
      padding: 0;
      background: white;
    }
    
    .nav ul {
      list-style: none;
      background-color: white;
      text-align: center;
      padding: 0;
      margin: 0;
    }
    
    .logo{
      position: absolute;
      float: right;
      margin-left: 1136px;
      margin-top:-3px;
    }
    
    .mainul {
      height: 145px;
      box-shadow: 1px 1px 1px #7e7e7ea6;
    }
    
    .mainul2{        
      height: 145px;
      box-shadow: 5px 9px 29px -2px #0000005e;
    }
    
    .pic-index{        
        position:relative;
        top:30%;
        float: right;   
        margin-right: 50px;
    }
    .pic-index img{
        max-width: 48px;
        max-height: 48px;        
    }
    
    .nav li {
      font-family: Varela Round;
      font-size: 1.2em;
      line-height: 40px;
      text-align: left;
        padding-right:;
    }
    
    .nav a {
      font-size:15px;
      margin-top:50px;
      margin-left:20px;
      text-decoration: none;
      color: #5a5a5a;
      display: block;
      padding-left: 15px;
    
      transition: .3s background-color;
    }
    
    .nav a:hover {
     color:#57c0ea;
    }
    
    .nav a.active {
      
      color: #444;
      cursor: default;
    }
    
    /* Sub Menus */
    .nav li li {
      font-size: .8em;
    }
    

    
    /*******************************************
       Style menu for larger screens
    
       Using 650px (130px each * 5 items), but ems
       or other values could be used depending on other factors
    ********************************************/
    
    @media screen and (min-width: 650px) {
      .nav li {
        width: 130px;
        border-bottom: none;
        height: 50px;
        line-height: 50px;
        font-size: 1.4em;
        display: inline-block;
        margin-right: -4px;
      }
    
      .nav a {
        border-bottom: none;
      }
    
      .nav > ul > li {
        text-align: center;
      }
    
      .nav > ul > li > a {
        padding-left: 0;
      }
    
      /* Sub Menus */
      .nav li ul {
        position: absolute;
        display: none;
        width: inherit;
      }
    
      .nav li:hover ul {
        display: block;
      }
    
      .nav li ul li {
        display: block;
      }
    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
 
   <div class="nav"> <ul class="mainul"> 
   <ul class="mainul2">
        <div class="logo"><img src="images/Logo-1.png"></div>
        <div class="pic-index"><img src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/256/Actions-help-about-icon.png"></div> 
        <li class="contact"><a href="#">צור קשר</a>
        <ul>
     </li>
    </ul>  
    <li class="services"><a href="#">שירותים</a>
    <ul> 
      <li><a href="#">Tutorial #1@@</a></li>
      <li><a href="#">Tutorial #2</a></li>
      <li><a href="#">Tutorial #3</a></li> 
    </ul> 
    </li>
         <li class="about"><a href="#">אודות</a></li>
         <li class="home"><a href="#">דף הבית</a></li>
      </ul>       
  </div>

Related


How can i make image hover in navbar

and Simon Medina I'm trying to learn how to do a hover on an image in the navbar , my goal is to have the div image "pic-index" be affected by the hover on the "HOME" link on the navbar and have the div change to Another image hovers. I really don't know what

How can i make image hover in navbar

and Simon Medina I'm trying to learn how to do a hover on an image in the navbar , my goal is to have the div image "pic-index" be affected by the hover on the "HOME" link on the navbar and have the div change to Another image hovers. I really don't know what

How can I make the image fade in and out on hover?

Gavin Lorenzo I'm pretty new to web developers now and I'm currently trying to make an image fade in and out when hovering over it. This is what I have now: html: <body> <img src=imgmonochrome.jpg id=img1> </body>

How can I fix the width of the navbar hover?

view Bye bye! Whenever I hover, there is a space above. If you look at the jsfiddle you will see that not all are hovered. It doesn't look good. I tried to put margin-top:0in .show-menu, but it doesn't work. What must be added or changed in my code? All help w

How can I make the navbar slightly transparent?

do I think I can make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css?fam

How can I make my navbar responsive?

Jeff Jeff I have this navbar on Codepen : http://codepen.io/DogburnDesign/pen/zymID . Everything is fine, but I've realized it's not responding. I'm pretty experienced in making websites, but I'm new to this kind of responsive stuff. Help? thanks. Here is the

How can I make the navbar slightly transparent?

do I figured I could make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css

How can I make the navbar slightly transparent?

do I think I can make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css?fam

How can I make the navbar slightly transparent?

do I think I can make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css?fam

How can I make the navbar slightly transparent?

do I think I can make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css?fam

How can I make the navbar slightly transparent?

do I think I can make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css?fam

How can I make this navbar stick correctly?

User 11918199 The navbar is sticking, but I followed some basic instructions on how to make it stick, which includes position: fixed; width: 100%; top: 0;but the problem is that it covers part of the page, which is its height (40px) now when someone clicks on

How can I make this navbar responsive?

Nicaea I want to make a navbar that has a hexagonal shaped logo and three "buttons" aligned as shown in this screenshot : https://prnt.sc/n8nm3q I managed to align them in fullscreen (1920x1080), but since my site has to be responsive, I don't know how to keep

How can I make this navbar stick correctly?

User 11918199 The navbar is sticking, but I followed some basic instructions on how to make it stick, which includes position: fixed; width: 100%; top: 0;but the problem is that it covers part of the page, which is its height (40px) now when someone clicks on

How can I make this responsive navbar work?

Robbie 1995 I am trying to make a responsive navbar with these 4 elements. However, if I drag the browser window to a certain point, it starts placing one of the 4 below the rest. But I don't know what I'm doing wrong. HTML: <div id="nav"> <ul> <

How can I make the navbar slightly transparent?

do I think I can make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css?fam

How can I make the navbar slightly transparent?

do I think I can make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css?fam

How can I make the navbar slightly transparent?

do I think I can make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css?fam

How can I make the navbar slightly transparent?

do I think I can make my site look better by making the navbar transparent so you can see a slightly dimmed version of the image below it. I can't find anything that tells me how to do this. Can someone help me? @import url(https://fonts.googleapis.com/css?fam