Solution 1 :

All you need is to remove overflow and padding-bottom to be like this

ul.ml-auto > li > a > span {
    font: 15px Roboto,sans-serif;
    font-weight: 500;
    position: relative;
    display: inline-block;
    color: #FFFFFF80;
}

Live Demo:

.navbar-custom {
  background-color: #484848;
}

ul.ml-auto>li>a>span {
  font: 15px Roboto, sans-serif;
  font-weight: 500;
  position: relative;
  display: inline-block;
  color: #FFFFFF80;
}

ul.ml-auto>li>a>span::before {
  position: absolute;
  content: attr(data-content);
  color: #00FFFF;
  clip-path: polygon(0 0, 0 0, 0% 100%, 0 100%);
  transition: clip-path 275ms ease;
  display: block;
  border-bottom: 2px solid #00FFFF;
  padding-bottom: 4px;
}

ul.ml-auto>li>a>span:hover::before {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
<!DOCTYPE html>
<html>

<head>
  <title>Bootstrap Resize</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
</head>

<body>
  <nav class="navbar navbar-custom navbar-expand-lg navbar-dark fixed-top py-2" id="mainNav">
    <div class="container">
      <a style="font: 20px Arial,sans-serif" class="navbar-brand js-scroll-trigger" href="#">HOME</a>
      <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>

      <div class="collapse navbar-collapse" id="navbarResponsive">
        <ul style="font: 15px Roboto,sans-serif" class="navbar-nav ml-auto">
          <li class="nav-item">
            <a class="nav-link js-scroll-trigger" href="#about"><span data-content="LOREM">LOREM</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link js-scroll-trigger" href="#expertise"><span data-content="LOREM">LOREM</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link js-scroll-trigger" href="#portfolio"><span data-content="LOREM">LOREM</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link js-scroll-trigger" href="#contact"><span data-content="LOREM">LOREM</span></a>
          </li>
        </ul>
      </div>

    </div>
  </nav>
</body>

</html>

Solution 2 :

adjust padding in a tag

.navbar-custom { 
  background-color: #484848;
}

ul.ml-auto > li > a > span{
  font: 15px Roboto,sans-serif;
  font-weight: 500;
  position: relative;
  display: inline-block;
  color: #FFFFFF80;
  overflow: hidden;
  padding-bottom: 5px;
}
ul.ml-auto > li > a > span::before {
  position: absolute;
  content: attr(data-content);
  color: #00FFFF;
  clip-path: polygon(0 0, 0 0, 0% 100%, 0 100%);
  transition: clip-path 275ms ease;
  display: block;
  border-bottom: 2px solid #00FFFF;
  padding-bottom: 4px;
}
ul.ml-auto > li > a > span:hover::before {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
.nav-link {
  padding: .5rem 1rem 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

<nav class="navbar navbar-custom navbar-expand-lg navbar-dark fixed-top py-2" id="mainNav">
    <div class="container">
      <a  style="font: 20px Arial,sans-serif" class="navbar-brand js-scroll-trigger" href="#">HOME</a>
      <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarResponsive">
        <ul style="font: 15px Roboto,sans-serif" class="navbar-nav ml-auto">
          <li class="nav-item">
            <a class="nav-link js-scroll-trigger" href="#about"><span data-content="LOREM">LOREM</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link js-scroll-trigger" href="#expertise"><span data-content="LOREM">LOREM</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link js-scroll-trigger" href="#portfolio"><span data-content="LOREM">LOREM</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link js-scroll-trigger" href="#contact"><span data-content="LOREM">LOREM</span></a>
          </li>
        </ul>
      </div>
    </div>
</nav>

Solution 3 :

The reason is bottom padding of span tag. you have applied only bottom padding.

Solution– apply equal padding on top and bottom side. As I have applied below.

 ul.ml-auto > li > a > span {
 font: 15px Roboto,sans-serif;
 font-weight: 500;
 position: relative;
 display: inline-block;
 color: #FFFFFF80;
 overflow: hidden;
 padding-bottom: 5px;
 padding-top: 5px;/*New added for equal space*/
}

Problem :

My bootstrap navbar looks like the following:
enter image description here
When I hover over to each of the LOREM’s, it looks like this:
enter image description here
How can I modify my code so that the LOREM’s have equal spacing at the top and bottom of the navbar, like this:

enter image description here

Please note that the underline must still appear as it is. I just need the LOREM’s to have equal spacing when it’s not hovered over. Here is my HTML and CSS code:

<!DOCTYPE html>
<html>
   <head>
       <title>Bootstrap Resize</title>
       <meta charset="utf-8"></meta>
       <meta name="viewport" content="width=device-width, initial-scale=1" ></meta>
       <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
       <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
   </head>

   <style type="text/css">
    .navbar-custom { 
    background-color: #484848;
    }

    ul.ml-auto > li > a > span{
    font: 15px Roboto,sans-serif;
    font-weight: 500;
    position: relative;
    display: inline-block;
    color: #FFFFFF80;
    overflow: hidden;
    padding-bottom: 5px;
    }
    ul.ml-auto > li > a > span::before {
    position: absolute;
    content: attr(data-content);
    color: #00FFFF;
    clip-path: polygon(0 0, 0 0, 0% 100%, 0 100%);
    transition: clip-path 275ms ease;
    display: block;
    border-bottom: 2px solid #00FFFF;
    padding-bottom: 4px;
    }
    ul.ml-auto > li > a > span:hover::before {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
   </style>

   <body>                 
    <nav class="navbar navbar-custom navbar-expand-lg navbar-dark fixed-top py-2" id="mainNav">
      <div class="container">
        <a  style="font: 20px Arial,sans-serif" class="navbar-brand js-scroll-trigger" href="#">HOME</a>
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarResponsive">
          <ul style="font: 15px Roboto,sans-serif" class="navbar-nav ml-auto">
            <li class="nav-item">
              <a class="nav-link js-scroll-trigger" href="#about"><span data-content="LOREM">LOREM</span></a>
            </li>
            <li class="nav-item">
              <a class="nav-link js-scroll-trigger" href="#expertise"><span data-content="LOREM">LOREM</span></a>
            </li>
            <li class="nav-item">
              <a class="nav-link js-scroll-trigger" href="#portfolio"><span data-content="LOREM">LOREM</span></a>
            </li>
            <li class="nav-item">
              <a class="nav-link js-scroll-trigger" href="#contact"><span data-content="LOREM">LOREM</span></a>
            </li>
          </ul>
        </div>

      </div>
    </nav>
   </body>
</html>

By