The Bootstrap navigation row smoothly adjusts its size, yet only partially highlights active or highlighted links

When viewing on a smaller screen, one of the links in this navigation (nav-pills, nav-justified) spans two lines, causing the other links to appear larger as well. While this may seem beneficial, active or highlighted links only partially fill the box, resulting in an unsightly appearance as depicted in the image below. Clearly not ideal, right?

Check out the nav row image here

Is there a way to ensure that the active or highlighted link fills up the entire box? Additionally, how can I vertically center the link within the box?

Here's the relevant HTML code snippet:

<nav> 
    <ul class="nav nav-pills nav-justified">
        <li><a href="#">Atmosphere</a></li>
        <li class="active"><a href="#">Food</a></li>
        <li><a href="#">Drink</a></li>
        <li><a href="#">Access &amp; Info</a></li>
        <li><a href="#">Coupons</a></li>
        <li><a href="#">Reservation</a></li>
    </ul>
</nav>

And the accompanying CSS style rules:

header, section, footer, aside, nav, main, article, figure {display: block;}

nav > ul > li {
    border: 4px #abcabc;
    border-style: double;
}

nav > ul > li > a {
    color: #c30200;
    font-family: Garamond, sans-serif;
    font-size: 18px;
}

Answer №1

Here is a suggestion:

If the highlighted section does not fill up the entire box, please share your code for further assistance.

To vertically center content, you can use the text-center class.

VIEW DEMO

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Brand</a>
        </div>
        <div class="collapse navbar-collapse text-center" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                        <li class="divider"></li>
                        <li><a href="#">One more separated link</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Personalize Drop-Down Selection

Currently implementing bootstrap on a site and seeking to enhance the dropdown menu customization. The default navbar appearance is present, with dropdown elements appearing upon hover. My goal is to include an icon next to each item in the navbar and ha ...

Animating Elements with CSS and HTML

Struggling with my website project, specifically creating a login page. The issue arises when resizing the browser, causing elements to look misaligned and chaotic. Before: view image here After: view image here /* Bordered form */ form { margin-l ...

Can you explain the variance between e-resize and ew-resize cursor styles?

Can you explain the differences between these cursor types? I'm noticing that they all appear as the same cursor in Chrome on Windows. .e-resize {cursor: e-resize;} .ew-resize {cursor: ew-resize;} .w-resize {cursor: w-resize;} <p>Mouse over t ...

The interaction of a horizontal scroll bar on a CSS Grid layout triggers the appearance of a vertical scroll bar

I am facing a challenge with my HTML layout. In Chrome, when the horizontal scroll bar is visible, a vertical scroll bar also appears. However, in Firefox, everything works fine. This issue seems to be related to the height of the div not auto-scaling prop ...

What is the best way to ensure an image is responsive in CSS and aligns perfectly in height with its neighboring text?

There is an image within the <img> tag and some text inside the <p> tag, both enclosed in a <div>. Although the image is responsive and resizes proportionally when the browser window changes size, there is an issue where as the text wrap ...

The Bootstrap dropdown feature is acting up when included in the header PHP file

I'm having an issue where the dropdown in my header.php file is not working when I include it in my home.php page. The navigation bar appears correctly, but the dropdown feature doesn't work. Can someone please assist me with this? Below are the ...

a:hover CSS style altering the behavior of buttons with images in a web browser

Earlier I attempted to ask this question from my phone, but it ended up being overly convoluted and confusing. Therefore, I have decided to start fresh after locating a working PC. Unfortunately, due to the sensitive nature of the project, I am unable to p ...

Choosing a single radio button is simple with these steps

Trying to display radio-buttons in the code below, but encountering an issue where all radio-buttons can be checked simultaneously. The desired functionality is to only allow one radio button to be checked at a time, preventing the selection of multiple op ...

How can we expand the functionality of bootstrap classes?

As I navigate my first steps with Bootstrap Twitter, I find myself in need of extending components. Specifically, I am looking to customize the navbar background without altering the original css file. My attempt involved creating a new class called .test ...

Differences in CSS between IE10 and Chrome are causing compatibility issues

Website in question: What is causing the difference in display between IE 10 and other browsers? The website appears to function correctly on Chrome: IE 10: ...

Angular 2: Enhancing Tables

I am looking to create a custom table using Angular 2. Here is the desired layout of the table: https://i.sstatic.net/6Mrtf.png I have a Component that provides me with data export class ResultsComponent implements OnInit { public items: any; ngO ...

Struggling to add information to a database table with PHP

Check out the code snippet below: Here is the HTML5 code block: <div class="col-md-8 blogger-right-container"> <form action="blogger_account.php" method="post" role="form" enctype="multipart/form-data"> < ...

problem with the picture and wrapper expanding to fill the entire width of the screen

I'm having an issue with the image I added and its hover effect. The image seems to be leaving space on both sides of the screen, even though I've included background-size: cover and width:100% in my code. Could someone please point out where I ...

Not compatible with certain browsers, scrollable wrapper in fullscreen

I am looking to create a unique layout with a fullscreen div on top of a footer. The main element (#wrapper) should have a fullscreen background image and be scrollable to reveal the footer underneath. Check out my code on JSFiddle: https://jsfiddle.net/t ...

applying a custom background image using CSS with local storage

Seeking to incorporate a base64 image stored in local storage under the key ImgStorage into the CSS background: data:image/png;base64,iVBORw0KGgoAAAANS...... Experimented with two approaches: 1) Loading from storage and placing in CSS tag: var TheImage ...

What could be causing my custom cursor to malfunction?

I've been attempting to customize the cursor image, but despite following all provided instructions, it's still not working: CSS: body, html { margin: 0px; padding: 0px; border: 1px solid red; cursor: url(images/rsz_red_crosshair.gi ...

A single background image split into several div elements

I am facing an issue regarding the background image placement in multiple divs. When I set the position to fixed, the image repeats when I resize the screen. However, changing it to absolute causes each div to have its own image. Is there a solution to fi ...

What steps do I need to take in order to make the navbar-collapse function properly with an animated

After successfully implementing a collapsible navbar with a hamburger icon for mobile view, I decided to add some extra styling and animation to the hamburger button. However, now the hamburger button remains visible even in desktop view, which is not what ...

What is the best way to extend a div to fill the full width of a webpage?

I'm struggling to align a div perfectly with the left, right, and top edges of the page. Despite trying various solutions suggested by others, I just can't seem to get it right! Any assistance would be greatly appreciated. Thank you. ...

Personalized design for Sweet alert 2

I am trying to customize a sweetAlert2 by defining a className, but it seems that the styling is not applying to the sweet alert. I have tried calling the class name "styleTitle" and various other names, but nothing seems to work. Could the issue be with t ...