How to align an unordered list vertically in the center using Bootstrap?

Trying to figure out why the ul within this parent div is not centered vertically. Here is a screenshot of the issue: https://i.sstatic.net/ZOc9M.png

<div className=" d-flex align-items-center bg-primary  ">
            <ul
              className="d-flex align-items-center bg-success"
              style={{ gap: "3em" }}
            >
              <li className="bg-danger">vision</li>
              <li>consorzio</li>
              <li>contatti</li>
            </ul>
          </div>

Struggling to get the bg-success class centered within the bg-primary div.

Answer №1

Oftentimes, ul elements will come with default margins that need to be removed:

For this, navigate to the global.css file and add the following code snippet:

ul {
   margin: 0;
}

Answer №2

<div className="d-flex align-items-center bg-primary">
  <ul className="d-flex align-items-center bg-success justify-content-center" style={{ gap: "3em" }}>
    <li className="bg-danger">vision</li>
    <li>consorzio</li>
    <li>contatti</li>
  </ul>
</div>

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

How can I configure VSCode to autocomplete both React props type and name?

Currently, I'm in the process of switching from WebStorm to VSCode. While VSCode does a good job autocompleting my prop names (especially since I'm also working with TypeScript), one feature I miss from WebStorm is its ability to not only autocom ...

Every time the page is refreshed, ExpressJS and NodeJS are working together to duplicate the array

var express = require("express"); var router = express.Router(); const fs = require("fs"); const path = require("path"); const readline = require('readline'); const directoryPath = path.resolve(__dirname,"../log ...

Determining in Express.js whether headers have been sent or not

As I develop a library that involves setting headers, I aim to provide a personalized error message in case the headers have already been sent. Rather than simply letting it fail with the default "Can't set headers after they are sent" message from No ...

Linking Java objects with Node.js variables

In this snippet of code, I am utilizing the 'java' module in node.js to create Java objects. Specifically, I am creating four Java objects and aiming to consolidate them as a single object by using the variable 'args' to store these Jav ...

Transforming a function into an array in TypeScript

I attempted to use the map() function on a dataURL array obtained from the usePersonList() hook, but I am struggling to convert my function to an array in order to avoid errors when clicking a button. import Axios from "axios"; import React, { us ...

"Unsuccessful jSON request made by Ajax resulting in undefined response

I've implemented an ajax call to fetch data from a json file and display it in an HTML table. Everything was working fine initially, but now it seems to be returning UNDEFINED. Could it be that the data from the json file hasn't finished loading ...

Making the toggle button functional on the navbar

Trying to customize my navbar for tablet and mobile devices is proving to be a challenge. I am looking for a way to make the dropdown button take up the entire page when clicked on. It seems like JavaScript might be the solution, but I'm not quite sur ...

Stop Autocomplete from changing the value in ReactJS Material UI

Looking for a solution with the Autocomplete component to restrict selection of specific values. Any ideas? const options = ["Option 1", "Option 2", "Option 3"]; const [value, setValue] = React.useState(options[0]); const [in ...

Is it feasible to forgo using next-redux-wrapper in Next.js for Redux? Can Context combined with useReducer suffice as the state manager in Next.js applications?

Looking for a state manager solution for my NextJS application, I decided to go with Redux. However, the process of incorporating it using next-redux-wrapper seems overly complicated. Some users have reported that the next-redux-wrapper has its flaws and ...

Navigate to the top of the page using Vue Router when moving to a new

Currently, in my Vue application, whenever I click on a <router-link>, it directs me to the new page but at the same scroll position as the previous one. This happens because the link only replaces the component. I am curious to know if there is a s ...

Finding and removing a specific CSS pattern from a webpage that has been loaded

Encountered a troublesome Amazon.com page that appears blank in print preview, specifically the Online Return Center\Your Return Summary page. After much troubleshooting on a locally saved copy of the webpage, I pinpointed the issue to a problematic l ...

Delete JavaScript functions and events from memory once the JavaScript code has been removed from the HTML file

I am encountering a situation with my website where popups loaded via ajax also load JavaScript code, which I want to remove when the popup is closed. The main site code looks like this: <body> ... <div id="popup" style="display:none"> < ...

How to Transfer Information Between Two React Components

I recently started learning React and I'm not sure how to approach this task. Basically, I have a list of cars and when the user clicks on each car, it should display detailed information about that specific car in a full-page slide. This is my curr ...

Javascript and CSS combo for creating a stylish fade effect

Hey everyone, I have a design challenge where I need to change the color of a picture inside a box when the user hovers over it. I have four boxes like this and my goal is to make everything else fade out when a user hovers over a specific box. Anyone kn ...

What is the best way to generate page elements in AngularJS when the total number of pages is already known?

I have a project where I am developing an application that showcases a JSON of "users" in an HTML5 table. This application is built using Bootstrap 3 and AngularJS. My goal is to implement pagination for this table. Instead of having an array to iterate t ...

In Vue, the concept of using the debounce method is not clearly defined

I am aware that using the arrow syntax for a method can cause 'this' to not be mapped to the Vue instance. In my case, I am utilizing lodash.debounce and I don't think I'm using the arrow syntax here? Encountering Error: Cannot read pr ...

Modify the CSS style of the select label and change the color of the currently selected option in MUI

For the past few days, I've been facing challenges with implementing MUI components while working on a page for a React app. I'm almost finished with my project, but there are 2 key things missing... On my page, I have utilized a Select and an ...

Utilize React router v6 for dynamic navigation within your application through programming techniques

React-router allows for the creation of links using the Link element, which are managed by react router itself. Internally, I notice it uses this.context.transitionTo(...). I am interested in performing navigation not from a link, but perhaps from a drop ...

Displaying Unicode CSS Font Awesome Icons as Boxes in a React Project

I have incorporated the jPlayer example into a create-react-app. Encountering an issue where font-awesome icons are displaying as boxes in this CodeSandbox illustration. https://codesandbox.io/s/peaceful-heisenberg-d59nz?fontsize=14&hidenavigation=1&a ...

Tips for updating the state of an individual component in ReactJS without having to re-render the entire component

As a beginner in ReactJS, I am seeking guidance on how to modify the state of a specific component that was created within a Map function. Imagine I have a basic component named panels, with multiple panel-items. Each panel-item is essentially one componen ...