Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda