What is the best way to arrange list items in this manner?

I am facing challenges with aligning elements properly on the navigation bar. I would like the words (home, players, about, contact) to be vertically centered in relation to the heart logo.

Here is how it currently appears:

This is how I want it to look (created using Photoshop):

The current code I am using:

body {
  padding: 0;
  margin: 0;
  font-size: 15px;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
  background-color: whitesmoke;
}

.container {
  width: 80%;
  margin: auto;
}


/* Header */

header {
  background: black;
  color: whitesmoke;
  padding-top: 30px;
  min-height: 50px;
  border-bottom: #fe1d61 4px solid;
}

header a {
  color: whitesmoke;
  text-decoration: none;
  font-size: 16px;
  font-weight: bold;
}

header ul {
  margin: 0;
  padding: 0 0 20px 0;
  list-style-type: none;
  text-align: center;
}

header li {
  display: inline;
  padding: 0 100px 0 100px;
  height: 30px;
}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">

<body>
  <header>
    <div class="container">
      <nav>
        <ul>
          <li><a href="index.html">HOME</a></li>
          <li><a href="players.html">PLAYERS</a></li>
          <li>
            <a href="index.html"><img src="img/00nation_logo.png" width="60px"></a>
          </li>
          <li><a href="about.html">ABOUT</a></li>
          <li><a href="contact.html">CONTACT</a></li>
        </ul>
      </nav>
    </div>
  </header>
</body>

Apologies if this question has been asked before, but I have searched for a solution and couldn't find one.

Answer №1

Here is a solution for adjusting the styling of your list items:

nav ul li {
    display: inline-block;
}

Answer №2

To center your image among others, utilize the vertical-align property. Give this a shot:

style="vertical-align: middle;"

Answer №3

To achieve the desired result, additional CSS needs to be added like so:

header li{
    display: inline;
    padding: 0 100px 0 100px;
    height: 30px;
    vertical-align: middle;   // this line should be included
    line-height: normal;      // also add this line
}

Make sure to check the Full Screen view for better visibility.

You can see a complete example below:

body{
    padding: 0;
    margin: 0;
    font-size: 15px;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
    background-color: whitesmoke;
}

.container{
    width: 80%;
    margin: auto;
}

/* Header */
header{
    background: black;
    color: whitesmoke;
    padding-top: 30px;
    min-height: 50px;
    border-bottom: #fe1d61 4px solid;
}

header a{
    color: whitesmoke;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
}

header ul{
    margin: 0;
    padding: 0 0 20px 0;
    list-style-type: none;
    text-align: center;
}

header li{
    display: inline;
    padding: 0 100px 0 100px;
    height: 30px;
    vertical-align: middle;
    line-height: normal;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <meta name="description" content="Norwegian-based esports organization with teams in CS:GO, Rocket League, and many other games.">
    <meta name="author" content="@__jmarcelo__">
    <link rel="stylesheet" href="./css/style.css">
    <title>00 Nation DNB | Home</title>
</head>
<body>
    <header>
        <div class="container">
            <nav>
                <ul>
                    <li><a href="index.html">HOME</a></li>
                    <li><a href="players.html">PLAYERS</a></li>
                    <li><a href="index.html"><img src="https://pbs.twimg.com/media/E-YiHwfXsAEAuiZ.jpg" width="60px"></a></li>
                    <li><a href="about.html">ABOUT</a></li>
                    <li><a href="contact.html">CONTACT</a></li>
                </ul>
            </nav>
        </div>
    </header>
</body>
</html>

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 set up a session in order to fetch information from a MySQL table

Can you guide me on implementing this session: (UserID is part of the login table) Session["UserID"]="usrName"; How can I incorporate the above code into the following script? using System; using System.Data; using System.Collections.Generic; using Sys ...

Displaying feedback messages and redirecting in Flask may result in the response being visible in the developer tools, but

Just starting out with Flask and encountering an issue. I am trying to determine if a response is empty, and if it is, display a message. The problem lies in the fact that even though the redirect works and the subsequent GET request returns the correct HT ...

Could a javascript loop be created to continuously activate a button with each iteration?

I have just started learning javascript and I am in the process of creating a website where users can change the background by simply clicking on a button. It's working perfectly fine so far, but I want to add another feature where the background imag ...

Tutorial on creating a loop for a function based on a specific condition

I have created two different div classes named box and box2. The box2 class can be dragged and dropped into any of the three box classes. Each box contains randomly chosen values from an array, while box2 contains its corresponding image for display. When ...

Changing the alignment of divs to center instead of the right side

I am currently working on a project that involves creating a tiled interface with responsive tiles. One issue I have encountered is that all the tiles are shifting to the left side of the div and not getting centered, no matter what I try. To see the pro ...

Design a Hover Mega Menu - click outside to close

Although there are similar topics on stackoverflow, the code I have is different from them. I am trying to achieve the following: If I click on the search box (the white square on the site), my search box should open If I open the search box and then cl ...

Using jQuery to reconstruct a list from a group of div elements

Seeking advice on how to convert an HTML section of divs into list items. Here is a sample of the current HTML structure: <div> <small>2019-10-31 10:41 Customer unregistered</small> </div> <div> <small>2019 ...

Encountered an issue with instafeed.js due to CORS policy restrictions

Trying to implement an API that provides JSON data for use in a function. Required Imports: Importing Jquery, instafeed.min.js, and the API (instant-tokens.com). <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js& ...

Stylish dropdown menu design inspired by W3CSS website

I recently implemented a CSS dropdown menu example that I found on a website, but it's not working with my code. I double-checked for typos but couldn't find any. Even when I tried to directly copy the code and replace the content with my own, i ...

Looking to retrieve the value of an input element within an ng-select in Angular 6?

Currently, I am working on a project where I aim to develop a customized feature in ng-select. This feature will enable the text entered in ng-select to be appended to the binding item and included as part of the multiselect function. If you want to see a ...

What steps should be taken to populate a grid row if a certain div element is not present?

I am currently using tailwindcss and have this specific HTML code snippet: REPL: https://play.tailwindcss.com/L8McFjGBVC <div class="grid grid-cols-12"> <div class="col-span-4 bg-red-300">1</div> <div class=&qu ...

Can Vuetify's grid system seamlessly integrate with the Bootstrap grid system?

According to information from the Vuetify documentation: The Vuetify grid draws inspiration from the Bootstrap grid. It involves the use of containers, rows, and columns to organize and align content. If I utilize Bootstrap grid classes in a Vuetify pr ...

Implement Bootstrap and CSS to ensure that my content appears below the header when users scroll down

I am struggling with a simple HTML page that is working well with CSS, but encountering an issue where the input form gets placed above the header when scrolling down. I want the header to always remain above the content even while scrolling. Any suggesti ...

Guide to effectively retrieving data from S3 and displaying a view at regular intervals of 4 seconds

In my current project, I am working on fetching a file from S3 and utilizing the data within that file to generate a map on a webpage. To achieve this task, I have set up an Express server along with the EJS templating engine for serving and rendering the ...

Creating and implementing a HTML template from scratch, devoid of any frameworks

Is there a way to create a quiz where all questions follow the same format and only one question is displayed at a time, without duplicating code? Perhaps using a template would be the ideal solution in this scenario. I appreciate your help. ...

PHP - contact form is live for just 2 hours daily

Hello, this is my first time here and I could really use some assistance. Please bear with me as English is not my strong suit compared to most people here, but I'll do my best to explain my query. So, I have a PHP script for a contact form on my web ...

Switching PHP include on an HTML page using JavaScript

I've been attempting to modify the content of the div with the ID "panel_alumno" using a JavaScript function that triggers when a button is clicked. My goal is to display a different table each time the button is pressed, but so far, I haven't be ...

Discover the Ultimate Guide on Altering the Course of Mega Menu!

I am working on a mega menu that is set to display in the usual direction. However, for the last two items, I would like them to appear from the button upwards. I'm not quite sure how to explain it. What I envision is something similar to this: ...

Include a <div> element to display the date in an HTML format, ensuring that the days and months

I am working on a project where I have a list of dates and I need to format them by adding div tags to separate the days, months, and years into different divisions. <div class="campaign">30/11/2016 - <a href="#" target="_blank">Dummy Text& ...

Guide to choosing and unchoosing a div / button using angularJs

I am attempting to create a functionality where items are displayed in a div instead of a list. When an item is clicked, the background color of the div changes and the item is added to a column. Clicking on the item again will revert it back to its origin ...