center text vertically in HTML list

Here at this festival, you'll find a unique menu on the sidebar. The menu is created using an HTML list with the following structure:

<ul class="nav nav-pills nav-stacked">
    <li class="active">
        <a href="index.html"><i class="icon-home"></i> Home</a>
    </li>
    <li>
        <a href="development.html">Development</a>
    </li>
    <li>
        <a href="management.html">Management</a>
    </li>
    <li>
        <a href="learning.html">Learning</a>
    </li>

    <!-- more menu entries -->
</ul>

The menu may not look perfectly aligned as some labels have icons next to them while others don't. This causes unevenness in appearance.

Is there a way to align the labels vertically without adding extra HTML elements, which would interfere with existing Bootstrap rules?

Answer №1

Give this a shot:

.nav-pills.nav-stacked > li > a {
  padding-left: 25px;
}


.nav-pills.nav-stacked > li > a > i {
  position: absolute;
  margin-left: -25px;
}

This code removes the icons from the regular flow of the page, shifts the text 25px to the right, and then places the icons 25px to the left for proper alignment.

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

Instructions on opening a modal and changing the source of the iframe within the modal

I currently have a modal within my application that is triggered by Bootstrap: <div class="modal full-page fade" tabindex="-1" role="dialog" id="fullpageModal"> <div class="full-page-content"> <button type="button" class="close" d ...

Is it possible to extract tooltip text from a website using Python and Selenium, specifically when the text is generated by JavaScript?

Can anyone help me retrieve the tooltip text that appears when I hover over the time indicating how long ago a game was played? You can find my summoner profile here. I have noticed that the tooltip text is not visible in the HTML code and suspect it may ...

Troubleshooting issue with ng-change function in AngularJS

I have been working on developing a web application that includes two dropdown lists. My goal is to update the data in dropdown list 2 whenever there is a change in dropdown list 1. <tr> <td> State </td> <td> ...

Rendering HTML in special characters with AngularJS is an innovative way to display

My last question may have been unclear, but I received a similar response from the server asking for clarification. The HTML is not rendering properly here. How can this be resolved? AppControllers.controller('create', ['$scope',' ...

Issue with reactivity not functioning as expected within VueJS loop without clear explanation

Struggling with implementing reactivity in vue.js within a loop? The loop renders fine, but firing an event updates the content without visibly rendering the data on the page. The latest version of vue.js is being used with bootstrap and jquery. Despite a ...

Does Courier New font have any downsides?

Is it possible to highlight text in a flex textarea using htmlText when certain font tags are not supported? I am looking for a font that is the opposite of Courier New so that when embedded in Flash and written with a specific color, I can achieve a hig ...

The justify-content property aligns single-line text horizontally, but its alignment may not be consistent when the text expands over

Seeking a deeper understanding of flexbox alignment, I decided to experiment with aligning content using only flexbox properties. One puzzling observation is how "justify-content" centers items with single lines of text (flex-item-1 and flex-item-5), but n ...

Utilizing a function within a span element

Can anyone help me figure out what I'm doing wrong while trying to toggle between a span and an input text field using the on function? If you want to take a look, I've created a fiddle for it here User Interface <div> <span >My va ...

Activate validation checks when the Div is loaded

I have a situation where I have multiple divs on my page, with only one visible at a time due to the use of an update panel. Within the third div, I need to implement validations using jQuery. <script src="http://ajax.aspnetcdn.com/ajax/jquery.valida ...

Setting up pagination for displaying data from a database on the client-side: a step-by-step guide

Greetings to all my fellow programmers on Stack Overflow! I am currently in the process of developing an e-commerce application using JSP. The products for the application are stored in a server-side database (Mysql) within a table named product. The prod ...

The FileReader.result is found to be null

Currently, I am in the process of setting up a page that allows users to upload a txt file (specifically a log file generated by another program) and then modify the text as needed. Initially, my goal is to simply console.log the text, but eventually, I pl ...

Ensure that the pseudo element inherits the background color of its parent

My dilemma involves multiple pseudo elements connected to diverse parent divs, each with a unique background color. My goal is for these before and after pseudo elements to mimic the background color of their respective parent divs without the use of Jav ...

Adjust the height of a div according to the width using CSS in a progressive manner

I'm looking to create a fluid container that adjusts its height gradually based on the width of the window (as the div's width is set to 100%). Similar to the behavior achieved with the aspect-ratio CSS rule, I want the height to smoothly increas ...

What is the process for setting up distinct radio types that will be separated?

I'm attempting to generate two separate questions with radio buttons in HTML. However, whenever I test it, I can only select one option even though I used to separate the questions to prevent interaction. Can anyone assist me? Do you agree? Yes ...

How to style an HTML table with just a bottom border

Is there a way to recreate the Staff Directory section of this page using only HTML, without having to rely on CSS and Javascript? Specifically, I want to create a table with only bottom borders/dividers for each line. Any suggestions on how to achieve thi ...

Safari not fully supporting CSS translate functionality

When I click a button on my app, an element slides into view and then slides out when I click the button again. This is achieved using a combination of CSS and JS. It works perfectly in Chrome and Firefox, but only partially in Safari. In Safari, the elem ...

Customize the appearance of the date input box in MUI KeyboardDatePicker

Currently, I am attempting to customize the appearance of the KeyboardDatePicker component including board color, size, font, and padding. However, none of the methods I have tried seem to be effective. Here is what I have attempted so far: 1 . Utilizing ...

switch out asterisk on innerhtml using javascript

Is there a way to replace the asterisks with a blank ("") in the innerHTML using JavaScript? I've attempted this method: document.getElementById("lab").innerHTML = document.getElementById("lab").innerHTML.replace(/&#42;/g, ''); I also ...

Instructions on how to navigate to a class page by clicking a button in a ReactJS interface

I am currently working with React and have implemented 3 classes in separate files. The App.js file contains a navbar and button, which when clicked, displays a table from 'Table.js'. I have also added buttons in front of each row in the table th ...

Feeling anxious about the abundance of fields within the table

Currently in the process of planning my upcoming project, a text-based MMORPG game. I'm tackling the design of certain aspects of the database and have encountered a new challenge. One feature of the game involves allowing players to purchase cars and ...