Position the Anchor element at the center with the flex attribute inside the li element

How can I center text anchor inside an li element using bootstrap (without CSS if possible)?

.nav-lt-tab .nav-item .nav-link {
    background-color: transparent;
    border-top: 3px solid #e0e0e0;
}
<html>

<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ec8e8383989f989e8d9cacd8c2dac2dc">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
</head>
<body>
<ul class="nav nav-lt-tab justify-content-center" id="tab" role="tablist">
                            <!-- Nav item -->
                            <li class="nav-item my-2 flex-fill ">
                                <a class="nav-link active text-dark ml-2 mr-2 " id="description-tab" data-bs-toggle="pill" href="#description" role="tab" aria-controls="description" aria-selected="false">Description</a>
                            </li>
                            <li class="nav-item my-2 flex-fill">
                                <a class="nav-link text-dark ml-2 mr-2" id="review-tab" data-bs-toggle="pill" href="#review" role="tab" aria-controls="review" aria-selected="false"><span class="ml-3">Feedback</span></a>
                            </li>
                               <li class="nav-item my-2 flex-fill">
                                <a class="nav-link text-dark ml-2 mr-2" id="review-tab" data-bs-toggle="pill" href="#review" role="tab" aria-controls="review" aria-selected="false"><span class="ml-3">Feedback</span></a>
                            </li>
                               <li class="nav-item my-2 flex-fill">
                                <a class="nav-link text-dark ml-2 mr-2" id="review-tab" data-bs-toggle="pill" href="#review" role="tab" aria-controls="review" aria-selected="false"><span class="ml-3">Feedback</span></a>
                            </li>
                            </ul>
                            </body
                            </html>

Answer №1

To center align the ul element, simply add the text-center class to it. Update your HTML code with the following snippet:

<ul class="nav nav-lt-tab justify-content-center text-center" id="tab" role="tablist">
     <li class="nav-item my-2 flex-fill ">
       <a class="nav-link active text-dark ml-2 mr-2 " id="description-tab" data-bs-toggle="pill" href="#description" role="tab" aria-controls="description" aria-selected="false">Description</a>
     </li>
     <li class="nav-item my-2 flex-fill">
       <a class="nav-link text-dark ml-2 mr-2" id="review-tab" data-bs-toggle="pill" href="#review" role="tab" aria-controls="review" aria-selected="false"><span class="ml-3">Feedback</span></a>
     </li>
     <li class="nav-item my-2 flex-fill">
       <a class="nav-link text-dark ml-2 mr-2" id="review-tab" data-bs-toggle="pill" href="#review" role="tab" aria-controls="review" aria-selected="false"><span class="ml-3">Feedback</span></a>
     </li>
     <li class="nav-item my-2 flex-fill">
       <a class="nav-link text-dark ml-2 mr-2" id="review-tab" data-bs-toggle="pill" href="#review" role="tab" aria-controls="review" aria-selected="false"><span class="ml-3">Feedback</span></a>
      </li>
</ul>

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

Having Trouble with Font Awesome Icon Loading in Search Box

Currently, I am working on a website located at . However, I am facing an issue where the font awesome icon is not loading properly and is only displaying a square. I have thoroughly reviewed the CSS and cannot identify any conflicting elements. Any assis ...

Tips for showcasing embedded content in WordPress without the need for scrolling

I am in the process of building a website. The sidebar menu contains a list of pages and posts from my WordPress blog. Whenever I select a menu item, the content is displayed within one of the templates I have created in an Iframe. However, there seems to ...

Adjust the appearance of an element based on user selection from a dropdown menu under certain circumstances

I am working on creating a dropdown menu using a JavaScript array. My goal is to display a specific span element when certain options are selected. For instance, I want the span to be shown only when options "a" and "c" are selected, but not when option " ...

Alter the color scheme using jQuery

Exploring the world of websites, I've come across many with a unique color switch feature. Users have the ability to choose a color, and the entire page transforms to match their selection. Check out these links for some examples... http://csmthe ...

Can I create a div with a rounded right side?

Is there a way to give a div a slightly rounded right side using CSS? If so, can you show me how in this fiddle template: http://jsfiddle.net/z2hejemu/ HTML <div class="rounded-side"> <p>By default, this div is rectangular. I would like t ...

Using pixel values to define CSS gradient color stops from the end

Currently, I am working on a project involving HTML/CSS/JS where the application has a fixed size and requires precise positioning of elements according to the provided designs. Working with pixel dimensions in CSS is not a concern due to the fixed window ...

The Bootstrap datepicker functions properly when used in plain HTML, but encounters issues when implemented within the .html()

Using HTML: <input class="m-ctrl-medium date-picker" size="16" type="text" id='lateETD1' name="dateRecv" value=""/> Not working with script: var ETD = $("#ETD"); ETD.html("<input class='m-ctrl-medium date-picker' id='la ...

Resizing a div dynamically based on its parent's position using JavaScript

I've been working on a code to dynamically resize multiple divs. The original code only resized one element, but I modified it to handle multiple div resizers. However, I'm facing an issue where there is a gap between the mouse and the div while ...

As the window size decreases, adjust the negative left margin to increase dynamically

Is there a way to adjust the margin-left property of mydiv-2 to become increasingly negative as the browser window is scaled down horizontally? #mydiv-1{ background-color:orange; width:60%; height:400px; margin-left: 150px } #mydiv-2{ backgr ...

Enhanced page flow with CSS and jQuery

I'm looking to improve the overall layout of my webpage, but I can't seem to pinpoint exactly what it is that I need! Imagine you have the following HTML structure: <section> <article> <h1>Article Header</h1> & ...

What is causing the issue of my oversized images not showing up on GoDaddy?

I recently uploaded my website on GoDaddy and I am facing an issue where some of my small images (sizes: 872 × 546px) are displaying perfectly fine, but the large ones (banners with a size of 2700 × 900px) aren't showing up. Does anyone have ...

What's the best way to add margin or padding to an SVG image within a v-app-bar

Seeking assistance with a seemingly simple question that can help enhance my understanding as I dive into using vue/vuetify for a new front end project. I am starting fresh and utilizing v-app-bar. Below is a snippet from my app.vue file: <template> ...

Saving users' dark mode preference on my website

I recently implemented a dark mode feature on my website. However, I noticed that when I enable dark mode and then refresh the page or navigate away, the preference resets. To address this issue, I am looking to store the user's preference as a cookie ...

Repeat Top Background

I am currently in the process of converting this design into HTML & CSS code. I am facing a challenge when it comes to repeating the background on the top section since the left and right parts do not use the same image file. Even after attempting to ...

Issue with Bootstrap 4 navigation tabs: dropdown items do not cycle through active tab panels

Whenever I utilize nav-tabs to toggle between tabpanels, it functions properly. However, there seems to be an issue when attempting to switch the active tabpanel using the links in the dropdown menu. Below is the HTML for my nav-tabs and dropdown menu, alo ...

Resolving problems with image dimensions in Angularjs and ionic framework

I'm attempting to achieve a design where the first image occupies 50% of the screen's height and 100% of its width, while the second image does the same. Please refer to the image below: https://i.sstatic.net/nwmRP.jpg ...

Using Accordions in Jquery to dynamically adjust page height during ajax calls

I am currently using AJAX to call in a page and animate its height successfully. However, I have encountered an issue with an accordion-like function that is supposed to toggle the visibility of an element and adjust the height of the containing element ac ...

JS changes the ID in HTML

I have a code snippet that displays "hello world" where each word has its own unique style applied using CSS. I am trying to implement a functionality where clicking on either "hello" or "world" will swap their respective styles. However, my current imple ...

Enhancing User Experience with React Hover Effects

I'm currently in the process of developing a React component library, and I'm looking to enhance the components with some stylish flair. Everything seems to be working smoothly, but I'm interested in changing the background color when a user ...

Having issues with Bootstrap 4 offset functionality - any suggestions on how to troubleshoot?

Having trouble with Bootstrap 4 offset not working, any suggestions on how to fix it? I've attempted multiple times but it's not working as expected compared to the previous version. Can anyone provide guidance on how to locate offsets in the lat ...