Center the list items vertically within a div by using the class list-inline

Struggling to vertically center the unordered list '.header-top-widget' within a div. Despite trying several methods, I can't seem to get it centered.

My attempts so far include:

.header-top-widget
{
  display:flex;
  align-items:center;
}

.header-top-widget a,
.header-top-social a {
  display: inline-block;
  margin-right: 30px;
  line-height: 50px;
  font-size: 14px;
  color: #fff;
}

.header-top {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 50px;
  background-color: #0e2737;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="37555858434443455647770219071906">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet"/>
<header class="header">
        <div class="header-top">
            <div class="container">
                <div class="d-flex justify-content-between">
                    <div class="header-top-widget">
                        <ul class="list-inline">
                            <li class="list-inline-item">
                                <a href="url" title="instagram" target="_blank" class="nav-link">
                                    <i class="fas fa-phone"></i> 96 Ernser Vista Suite 437, NY, US
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="instagram" target="_blank" class="nav-link">
                                    <i class="fas fa-envelope-open-text"></i> (123) 456-78-910
                                </a>
                            </li>
                        </ul>
                    </div>
                    <div class="header-top-social">
                        <ul class="header-top-social list-inline">
                            <li class="list-inline-item">
                                <a href="url" title="instagram" target="_blank">
                                    <i class="fab fa-instagram-square"></i>
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="twitter" target="_blank">
                                    <i class="fab fa-twitter"></i>
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="facebook" target="_blank">
                                    <i class="fab fa-facebook-f"></i>
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="linkedin" target="_blank">
                                    <i class="fab fa-linkedin"></i>
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="skype" target="_blank">
                                    <i class="fab fa-youtube"></i>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <nav class="">

        </nav>
    </header>

Looking for assistance on why the ul element isn't centering within the div using flexbox. Any semantic errors in my approach? Have scoured various Stack Overflow threads but still struggling. Any workarounds or solutions would be greatly appreciated.

Please provide guidance on how to achieve the desired vertical centering.

Answer №1

To address the issue, a temporary solution may involve adjusting the line heights for the social media icons and widgets.

.header-top-widget a,
.header-top-social a {
  display: inline-block;
  margin-right: 30px;
  line-height: 50px;
  font-size: 14px;
  color: #fff;
}

/* Decreased line height for widgets */
.header-top-widget a{
  line-height: 30px;
}

.header-top {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 50px;
  background-color: #0e2737;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6c0e0303181f181e0d1c2c59425c425d">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet"/>
<header class="header">
        <div class="header-top">
            <div class="container">
                <div class="d-flex justify-content-between">
                    <div class="header-top-widget">
                        <ul class="list-inline">
                            <li class="list-inline-item">
                                <a href="url" title="instagram" target="_blank" class="nav-link">
                                    <i class="fas fa-phone"></i> 96 Ernser Vista Suite 437, NY, US
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="instagram" target="_blank" class="nav-link">
                                    <i class="fas fa-envelope-open-text"></i> (123) 456-78-910
                                </a>
                            </li>
                        </ul>
                    </div>
                    <div class="header-top-social">
                        <ul class="header-top-social list-inline">
                            <li class="list-inline-item">
                                <a href="url" title="instagram" target="_blank">
                                    <i class="fab fa-instagram-square"></i>
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="twitter" target="_blank">
                                    <i class="fab fa-twitter"></i>
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="facebook" target="_blank">
                                    <i class="fab fa-facebook-f"></i>
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="linkedin" target="_blank">
                                    <i class="fab fa-linkedin"></i>
                                </a>
                            </li>
                            <li class="list-inline-item">
                                <a href="url" title="skype" target="_blank">
                                    <i class="fab fa-youtube"></i>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <nav class="">

        </nav>
    </header>

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

PHP HTML failing to recognize "mandatory" attributes

I'm facing an issue with adding validation for an empty field. When the field is left empty, the form should not be submitted. However, the "required" attributes seem to be ineffective in achieving this. Birthdate: <select name="month" r ...

Sending Email Form Producing Blank Page

My website's homepage is currently on a testing server. When I submit the form, the page appears blank, but it is still successfully sending the email. Another issue I am facing is that the checkbox values are not being displayed in the email. It see ...

Hide only the table that is being clicked on, not all tables

Essentially, I am using document.querySelectorAll() to retrieve an array of div elements. In my function, handleClick(), each time the button is clicked, I want to hide the table associated with that specific button. This is the current situation: https:/ ...

During testing, the Vuetify expansion panel body is hidden with a display none style

Greetings! I am currently facing an issue while debugging my testing site. The problem is that the expansion panels are not displaying due to a style attribute attached to the div element of v-expansion-panel__body. Strangely, this issue does not occur on ...

How do I overwrite this calculation using JQuery?

I have a website: link There are two pages on my site that have the same div elements... I want one page to perform a certain calculation on the divs, and another page to perform a different calculation... New JavaScript Code: jQuery(document).ready(fu ...

The website functions well in responsive design mode on an iPad screen, but encounters issues when viewed on an actual

The website is functioning well in responsive design mode on an iPad screen, however it seems to be having some issues specifically on iPad devices. I have tested it on all other devices and it works perfectly fine, but for some reason not on iPads. Feel ...

Utilizing Z-Index placement in CreateJS

I'm struggling to adjust the z-index for my line Graphic(). My goal is to ensure that the line always appears behind the other two shapes. Based on my understanding, the first element added has a z-index of 0, the second one has a z-index of 1, and s ...

How to perfectly align a button at the center and position it in the forefront?

I'm attempting to place a button in front of my video and center it on the video. I've tried using position-relative to bring it in front and flex to center it vertically and horizontally, but it's not working as expected. The z-index is cor ...

Customizing input class in Material-UI Autocomplete with React

I'm currently working on a React project and utilizing Bootstrap for the front-end. On top of that, I've incorporated an Autocomplete library from Material-UI. #ref: https://material-ui.com/components/autocomplete/ Challenge: My attempt to inco ...

Ensure that the body background image remains stretched and perfectly centered regardless of the screen resolution

I am having an issue with vertical centering on a website I created. Everything looks fine on my monitor, but at higher resolutions, the tables don't align in the center and the image shrinks. How can I ensure that everything stays aligned properly? ...

Achieving Equal Height for Two Bootstrap 4 Columns with Scrollbar

I've been searching everywhere for a solution to this problem. My goal is to design a page with a video player on the left side and a chat on the right side. I am using the embed-responsive class for the video player so that it adjusts its size based ...

Switch up the current Slick Carousel display by utilizing a div element

We have implemented the slick carousel to show only one slide at a time within the <div class='item__wrapper'>. Beneath this are three items, and we want the slick carousel to update when any of these items are clicked. Issues Using item ...

Centering a card on the screen in Bootstrap 5 can easily be achieved by using the new alignment classes, similar to how the `<center></center>` tag used

I'm having trouble getting a card to center on the screen. Here's what I've tried, but it's not working: <div class="d-flex aligns-items-center justify-content-center card text-center w-75"> <div class="card ...

What is the best way to flip the pentagon shape made with CSS?

I need assistance in creating a downward-pointing pentagon shape. However, I am unsure of how to define the points on the shape. #pentagon { margin:70px 0 5px 20px; position: relative; width: 110px; border-width: 100px 36px 0; border-style: solid; ...

Error encountered during file upload - file field :input not found

I'm dealing with some HTML that looks like this: <div id="promocodesUpload"> <div class="qq-uploader"> <div class="qq-upload-drop-area" style="display: none;"> <span>Drop </span> </div> <a class=" ...

Quick access to HTML URLs without the need for page names

I'm having trouble finding the right search terms. Is there a way to simplify the URL links on my website? For instance: Current URL structure: websitename.com/about_us_what_we_do.php Desired URL structure: websitename.com/what-we-do Another e ...

Save the selected value from the dropdown menu and automatically check the corresponding checkbox when it

I'm attempting to update the 'value' of a checkbox once an item is chosen from a dropdown list and then the checkbox itself is clicked. I have created a jQuery function that captures the value from the dropdown list (I omitted the code for t ...

Utilize jQuery to hide and then show elements based on text input

Recently, I came across a useful jQuery filter example that sparked my interest. To test it out, I created my live example and shared the code on CodePen (or you can check out the Fiddle if you prefer). One issue I encountered was that after entering text ...

Angular2 - Incorporating a New Attribute

I am working with the following Angular2 code: <ngx-datatable-column prop="id" name="ID"> <template ngx-datatable-cell-template let-row="row" let-value="value"> <a [routerLink]="['/devicedtls',r ...

Adjust the font size of the Facebook Comments Plugin

Does anyone know how to adjust the font size within a Facebook Comment iframe? I attempted to utilize a jquery script with the append method in hopes of injecting my CSS file into the iframe, but unfortunately it did not yield any result. Is modifying the ...