Problem with mouse over in image

Asked

Viewed 45 times

1

I would like to know how I can move my menu in an image I made. I wanted to put the menu on the left side for example. Here is my menu: https://gyazo.com/3cc836a7cb1b825800abe4f8b0b309e7

Here is my code:

<!-- Icon -->
    <div id="user">
        <img id="icon" align="left" style="position:absolute; top:2%; right:7.3%; " width="100px" src="https://cdn4.iconfinder.com/data/icons/small-n-flat/24/user-alt-128.png"  >
         <div id="nav_menu" style="position:absolute; top:2%; right:7.3%; ">
            <ul>
                <li id="l1"> -- </li>
                <li> -- </li>
                <li> -- </li>
                <li> -- </li>
            </ul>
   </div>

JS

  $("#icon").mouseover(function() {
            $('#nav_menu').slideDown();
        });

    $("#icon").mouseleave(function(){
            $('#nav_menu').slideUp();
    });

1 answer

4


#user {
  position: relative;
}
#user #nav_menu {
  position: absolute;
  left: 100px;
  top: 0;
  background-color: #000;
  width: 100px;
  visibility: hidden;
  height: 0;
  transition: all 0.25s ease;
  overflow: hidden;
}
#user:hover #nav_menu {
  visibility: visible;
  height: 100px;
}

#user #nav_menu ul li {
  color: #FFF;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Icon -->
<div id="user">
  <img id="icon" align="left" width="100px" src="https://cdn4.iconfinder.com/data/icons/small-n-flat/24/user-alt-128.png">
  <div id="nav_menu">
    <ul>
      <li id="l1">Link 1</li>
      <li>Link 2</li>
      <li>Link 3</li>
      <li>Link 4</li>
    </ul>
  </div>
</div>

  • Thanks for the help, but the menu is still on top of the image, and it was not quite what I want to do, I wanted to move to the left, so that still to see the icon

  • Where do you want the menu to be and where do you want the image to be ? Explain it better in your question. Otherwise it is difficult for us to help you.

  • I’d like it to be possible to put the menu on the right or left side of the image, not on top of the image, you know? I tried the align but it didn’t take effect

  • I edited the code, see if it’s what you need.

  • That’s exactly it !!! Thanks !

  • If it helped you, please mark the answer as sure. @Paulo

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.