JSFiddle - React, Tailwind, and code Playground

HTML

<ul id="menu">
  <li><a href="#" title="Menu a">Menu a</a></li>
  <li><a href="#" title="Menu b">Menu b</a></li>
  <li><a href="#" title="Nested Menu">Nested Menu</a>
    <ul>
      <li><a href="#" title="Menu Item">Menu Item</li>
      <li><a href="#" title="Long Menu Item">Long Menu Item</a></li>
      <li><a href="#" title="Longer Menu Item">Longer Menu Item</a></li>
      <li><a href="#" title="Longer Menu Item">An Even Longer Menu Item</a></li>
    </ul>
  </li>
  <li><a href="#" title="Menu z">Menu z</a></li>
</ul>

CSS

<style type="text/css" media="all">
* {
    padding:0; 
    margin:0;
}
body, html {
    width: 100%;
    height: 100%;
}
#wrapper {
    width: 800px;
    height: 100%;
    margin: auto;
}
#menu {
    margin: 0 0 0 8px; 
    padding: 0;
    font-size: 14px; 
    font-weight: normal;
}

#menu ul {
    list-style-type:none; 
    list-style-position:outside; 
    position:relative; 
    z-index:300; 
    height: 32px;
    font-weight:bold; 
    white-space: nowrap;
    padding:0;
} 
#menu a {text-decoration:none; 
    line-height: 32px;
        display: block;
} 
#menu a:hover {

} 
#menu li {
    float:left; 
    position:relative; 
    display: inline; 
    list-style-type: none; 
    padding: 0 20px;
    background: #ccc;
} 
#menu ul {
    position:absolute; 
    display:none; 
    left:0px;
    background: #BDCCD4;
    width:100%;
} 
#menu ul a, #menu li a {
    display: block;
}
#menu li ul {
    background: #BDCCD4;
    display:block;
}
#menu li ul a {
    font-weight: normal;
    height:auto; 
    float:left;
        display: block;
} 
#menu ul ul {
    padding: 0 9px;
    display:block;
} 
#menu li ul li {
    padding: 0 9px;
    background: #BDCCD4;
        padding: 0 20px;
}
#menu li:hover {
    background: #ddd;
    height: 32px;
}
#menu li li:hover, #menu li li li:hover {
    background: #ddd;
    height: 32px;
}
#menu li a:link, #menu li a:visited {
    text-decoration: none;
    color: #003E7E;
    margin: auto;
}
</style>

JavaScript

$(document).ready(function(){
  $("#menu > li > ul").each(function() { // Loop through all the sub LIs
    var Widest=0; // We want to find the widest LI... start at zero
    var ThisWidth=0; // Initiate the temporary width variable (it will hold the width as an integer)

    $($(this).children()).each(function() { // Loop through all the children LIs in order to find the widest
      ThisWidth=parseInt($(this).css('width')); // Grab the width of the current LI
  
      if (ThisWidth>Widest) { // Is this LI the widest?
        Widest=ThisWidth; // We got a new widest value
      }
    });

        Widest+='px'; // Add the unit
        
        $(this).parent().css('width',Widest);
        $(this).children().css('width',Widest);
  });
});