JSFiddle - React, Tailwind, and code Playground

HTML

<!-- user account photo and nav -->
<div id="userAcct" class="check">

  <div class="user-img"><img src="https://s3.amazonaws.com/uifaces/faces/twitter/adellecharles/128.jpg">
    <i class="fa fa-caret-down" aria-hidden="true"></i></div>

  <!-- link area -->
  <div id="myDropdown" class="navContent">
    <a href="index.php?action=logout">Log Out</a>
  </div>

</div>

CSS

#userAcct {
  display: inline-block;
  float: right;
  margin-right: 15px;
  height: 40px;
  width: 50px;
}

.user-img {
  height: 30px;
  border-radius: 50%;
  margin-right: 5px;
}

.user-img img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 50%;
  padding: 0;
  margin: 0px;
}

.navContent {
  position: absolute;
  top: 50px;
  right: 0;
  background-color: #06dd2a;
  width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  display: none;
}

.navContent a {
  text-decoration: none;
  display: block;
  padding: 5px 10px;
  margin: 5px;
  color: #666666;
  font-weight: bold;
}

.navContent a:hover {
  background-color: #666666;
  color: #06dd2a;
}

.show {
  display: block;
}

JavaScript

/* When the user clicks on the button, 
toggle between hiding and showing the dropdown content */
document.getElementById("userAcct").addEventListener("click", function (event) {
event.stopPropagation();
  document.getElementById("myDropdown").classList.toggle("show");
});


// ****REMOVE SCRIPT BELOW  AND IM ABLE TO OPEN THE MENU CLICKING ON THE PICTURE-----ADD THIS SCRIPT AND IT ONLY ALLOWS THE ME TO OPEN MENU CLICKING BELOW THE PICTURE

//*****Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
  if (!event.target.matches('.check')) {

    var dropdowns = document.getElementsByClassName("navContent");
    var i;
    for (i = 0; i < dropdowns.length; i++) {
      var openDropdown = dropdowns[i];
      if (openDropdown.classList.contains('show')) {
        openDropdown.classList.remove('show');
      }
    }
  }
}