Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
How to reduce border-bottom width form one side in html?

Actually I have to show bottom bar to currently active page. I am using ternary operator in PHP . The bottom bar is showing up but its horizontal width is a bit extra . I'm not been able to reduce its width . Here's a picture of it:

https://i.stack.imgur.com/9mWRJ.png

Here's ternary operator I used:

 <ul class="navbar-nav me-auto mb-2 ms-auto mb-lg-0">
                    <li class="{{'/' == request()->path() ? 'nav-item' : ''}}">
                        <a class="nav-link" href="{{route('home')}}">Home</a>
                    </li>
                    <li class="{{'novels' == request()->path() ? 'nav-item' : ''}}">
                        <a class="nav-link" href="{{route('novels')}}">Novels</a>
                    </li>
                    <li class="{{'about' == request()->path() ? 'nav-item' : ''}}">
                        <a class="nav-link" href="{{route('about-us')}}">About Us</a>
                    </li>
                    <li class="{{'contact' == request()->path() ? 'nav-item' : ''}}">
                        <a class="nav-link" href="{{route('contact-us')}}">Contact Us</a>
                    </li>
                </ul>

Here's the css:

 .nav-item {
    border-bottom:3px rgb(0, 0, 0) solid;
   margin-bottom: 19px;
   }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

First of all, the problem is not in the PHP (rather Smarty or Blade template engine) logic. The problem is in your CSS definition. You set border of your <li> items.

Proposed solution

Please use the css class nav-item for all your <li> in your navbar section. Because all of these <li> elements in your navbar describe an navigation item independent on the fact that, whether the current page equals one of them or not.

Use rather an additional class like current for marking the navigation item of actual page. I did it for you.

<ul class="navbar-nav me-auto mb-2 ms-auto mb-lg-0">
    <li class="nav-item {{'/' == request()->path() ? 'current' : ''}}">
        <a class="nav-link" href="{{route('home')}}">Home</a>
    </li>
    <li class="nav-item {{'novels' == request()->path() ? 'current' : ''}}">
        <a class="nav-link" href="{{route('novels')}}">Novels</a>
    </li>
    <li class="nav-item {{'about' == request()->path() ? 'current' : ''}}">
        <a class="nav-link" href="{{route('about-us')}}">About Us</a>
    </li>
    <li class="nav-item {{'contact' == request()->path() ? 'current' : ''}}">
        <a class="nav-link" href="{{route('contact-us')}}">Contact Us</a>
    </li>
</ul>

Then you should use the following CSS definition:

.nav-item.current a.nav-link{
    border-bottom:3px black solid;
    padding-bottom: 10px;
}

Please upvote and accept this answer, if it solves your problem.

Here is a screenshot of my solution:

enter image description here

about 4 years ago · Juan Pablo Isaza Report

0

I'm not able to read or test your code. We may require the code where you declared the space between your nav-item (li); however, if the space between is caused by padding-right, then change it to margin-right, or get that look from flex gap; it should work.

//no changes needed in this code
 .nav-item {
    border-bottom:3px rgb(0, 0, 0) solid;
   margin-bottom: 19px;
   }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!