0

I want my text to be underlined when it's active but when I did it looks like this:

image 1

I just only want the text to get underlined, if I used text-decoration:underline it underline the word but the I don't know how to make a gap between the text and the underline. I added new class .currents.

Here is my code:

<header id="header" class="transparent-header" data-sticky-class="not-dark">
  <div id="header-wrap" style="height:180px;">
    <!-- Primary Navigation
============================================= -->
    <nav id="primary-menu" class="style-2 center">
      <div id="primary-menu-trigger">
        <i class="icon-reorder"></i>
      </div>
      <div style="text-align:center">
        <ul class="one-page-menu" data-easing="easeInOutExpo" data-speed="1250" data-offset="65">
          <li>
            <a href="index.html"><div>Home</div></a>
          </li>
          <li>
            <a href="about.html"><div>WHO WE ARE</div></a>
          </li>
          <li>
            <a href="products.html"><div>WHAT WE TRADE</div></a>
          </li>
          <li>
            <a href="services.html"><div>SERVICES</div></a>
          </li>
          <li class="currents">
            <a href="logistic.html"><div>LOGISTICS</div></a>
          </li>
          <li>
            <a href="contact.html"><div>CONTACT</div></a>
          </li> 
        </ul>
      </div>
    </nav><!-- #primary-menu end -->
    <br>
  </div>
</header><!-- #header end -->

CSS:

.currents {    
  height: 3em;
  border-bottom: 1px solid ;
  /* margin-bottom: 5px;*/      
}

Here is the working jsfiddle. Thanks in advance

https://jsfiddle.net/light22/atzL4ahu/#&togetherjs=eLF0v1iEs8

2

2 Answers 2

2

You can use border-bottom (instead of text-decoration:underline) and padding-bottom to achieve your wish.

Like this:

a {
  text-decoration:none;  
  display:inline-block;
  border-bottom: 1px solid;
}

.gap {
  padding-bottom:15px;
}
<a href="#">without gap</a>
<a href="#" class="gap">with gap</a>

Sign up to request clarification or add additional context in comments.

1 Comment

Accept this as the answer by clicking the checkmark below the voting arrows.
1

You could wrap the text in a <span> tag. Here's a working JSFiddle demonstrating this.

https://jsfiddle.net/j7wo5pxx/

1 Comment

Mosh Fue's answer also works, and should be the accepted answer. It's a simpler solution which doesn't make use of the extra markup. I answered with this only as an alternative.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.