Even with the use of Display Flex, the menu and text remain misaligned

Hey there! I've been working on recreating a website to improve my skills, and I'm currently focused on replicating the navigation bar of this site:

I'm facing an issue with aligning the left line in the nav bar. Instead of being on the same line, they seem to overlap each other. The left part aligns perfectly, but the right side is giving me some trouble.

After spending hours each day for the past month learning CSS, I'm starting to feel frustrated that I still can't get a simple navbar done right.

Below are snippets of my HTML and CSS:

* {
  list-style: none;
  background-color: black;
  font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande",
    "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
  color: rgb(221, 213, 213);
  margin: 0;
  padding: 0;
}

.arte-logo {
  height: 45px;
  margin: 0;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-left ul {
  display: flex;
}

.nav-right ul {
  display: flex;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Documentaires et reportages</title>
    <link rel="stylesheet" href="style.css" />
    <link
      rel="icon"
      href="/Users/jeandizian/Documents/Code/space/Arte/Assets/imgs/arte-icon.png"
    />
  </head>
  <body>
    <nav>
      <div class="nav-left">
        <ul>
          <li>
            <img
              class="arte-logo"
              src="/Users/jeandizian/Documents/Code/space/Arte/Assets/imgs/arte-logo.png"
              alt="arte logo"
              ;
            />
          </li>
          <li><span>&#9783;</span></li>
          <li>Guide TV</li>
          <li>Direct</li>
          <li>Bientôt en ligne</li>
          <li>Arte Concert</li>
        </ul>
      </div>
      <div class="nav-right">
        <ul>
          <li><span>&#9784;</span></li>
          <li><span>&#8853;</span></li>
          <div class="connecter">
            <li><span>&#9865;</span></li>
            <li>Se connecter</li>
          </div>
          <li>ARTE en 6 langues</li>
        </ul>
      </div>
    </nav>
  </body>
</html>

Answer №1

Simply having align-items: center on the navbar won't suffice. This only aligns the nav-left and nav-right elements. You also need to ensure that the content within these elements is aligned as well.

* {
  list-style: none;
  background-color: black;
  font-family: "Lucida Sans", "Lucida Sans Regular", "Lucida Grande",
    "Lucida Sans Unicode", Geneva, Verdana, sans-serif;
  color: rgb(221, 213, 213);
  margin: 0;
  padding: 0;
}

.arte-logo {
  height: 45px;
  margin: 0;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-left ul {
  display: flex;
  align-items: center;
}

.nav-right ul {
  display: flex;
  align-items: center;
}

.connecter {
  display: flex;
  align-items: center;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Documentaries and Reports</title>
    <link rel="stylesheet" href="style.css" />
    <link
      rel="icon"
      href="/Users/jeandizian/Documents/Code/space/Arte/Assets/imgs/arte-icon.png"
    />
  </head>
  <body>
    <nav>
      <div class="nav-left">
        <ul>
          <li>
            <img
              class="arte-logo"
              src="/Users/jeandizian/Documents/Code/space/Arte/Assets/imgs/arte-logo.png"
              alt="arte logo"
              ;
            />
          </li>
          <li><span>&#9783;</span></li>
          <li>TV Guide</li>
          <li>Live</li>
          <li>Coming Soon Online</li>
          <li>Arte Concerts</li>
        </ul>
      </div>
      <div class="nav-right">
        <ul>
          <li><span>&#9784;</span></li>
          <li><span>&#8853;</span></li>
          <div class="connecter">
            <li><span>&#9865;</span></li>
            <li>Log In</li>
          </div>
          <li>ARTE in 6 Languages</li>
        </ul>
      </div>
    </nav>
  </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

Issue with extra spacing within a div element in Bootstrap 5

Why is there extra spacing on the right side of my div? The image and text are supposed to take up 50% of the screen each. However, for some reason, there is additional spacing on the right that prevents this from happening. I am using Bootstrap 5. Click ...

Troubleshooting problems with CSS when zooming in and out

My CSS is designed for screen sizes larger than 1100 pixels. However, when I zoom in using ctrl and the plus sign, the center container on the page fails to wrap properly and suddenly breaks. HTML: <div id="outer_footer_bottom"> <div class=" ...

Improving the layout of text by adjusting the width within a flex-box styled card

I have a card with the style property "display: flex;" applied to it along with other stylings, all of which are checked in the snippet below. My goal is for the text within the card to move to a new line once its width reaches either 120px or 7 ...

Creating a dynamic side navigation menu that adjusts to different screen sizes

I have been working on a project's webpage that was initially created by another Software Engineer. After he left, I continued to work on the webpage. The issue I encountered is that he preferred a side menu over a navbar using the left-panel and righ ...

Utilizing Google Maps and navigation features directly in the mobile application

I am currently working on an app with the Ionic framework and I'm looking to incorporate Google Maps and navigation directly into the app without having to redirect users to the Google Maps application. My development stack includes TypeScript, HTML, ...

Identify the moment when the SPAN element reappears in sight

I have a question that may have been asked before, but I haven't found a satisfactory answer yet. Within my HTML code, I have a SPAN element with an onclick event, like so: <span onclick='loadDiv()'>Text</span> When a user cli ...

Unable to resize images in Firefox

Why is it that resizing doesn't seem to work in Firefox but functions fine in Internet Explorer? I'm struggling to find a way to make it consistent across all browsers. My goal is to resize the width to 800 and height to 475, disable maximizing t ...

Update information on the page seamlessly with user-friendly URLs, no need for hashtags or question marks!

I am faced with the common challenge of maintaining a website where I want the header and menu divs to remain constant while the content div changes based on user input through the menu. To achieve this, I used PHP include, which works well, but causes th ...

Building an HTML table using arrays and JSON information

I am looking to generate an HTML table... Here is the code snippet: $result = curl_exec($ch); curl_close($ch); $json = json_decode($result); foreach ($json->data->reservations as $element) { print_r($element); }// Upon running this, I received ...

MathJax only functions properly on Firefox Browser; for all other browsers, it fails to work as intended

I have integrated MathJax into a website that I designed. Everything works perfectly fine on Firefox, but there seems to be an issue with MathJax input when I try to open the site on Opera, for example. Here is the code snippet that is causing problems on ...

Using Javascript to navigate links in a list using keyboard arrow keys

When links are not wrapped in other elements, I am able to change focus easily. Here is how it works: HTML <a id="first" href="#" class='move'>Link</a> <a href="#" class='move'>Link</a> <a href="#" class=&a ...

Exploring a website's HTML structure with Beautiful Soup in Python to pinpoint and extract certain tags

Here is the HTML code for reference: https://i.sstatic.net/Bs2DW.png I am attempting to extract specific information using Python code from the tags following "product-card__title" and "product-card__price". In this case, I need it to return the name and ...

The height of each Bootstrap column is equal to the height of its corresponding

I am trying to prevent the column height from being equal to the row height in Bootstrap. Here is my code snippet: <div class="row justify-content-center text-center"> <div class="col-sm-3"></div> <div class="col-sm-9"></d ...

Challenges with incrementing in Jquery's each loop and setTimeout

http://jsfiddle.net/fxLcy/ - an example showcasing the use of setTimeout. http://jsfiddle.net/fxLcy/1/ - this demo does not include setTimeout. Although all elements are correctly positioned, I am in need of that delayed animation =/ My goal is to arrang ...

Can you please provide guidance on implementing automatic horizontal scrolling with pauses between each div?

setInterval(function scroll() { $(".box_auto").each(function(i, e) { $("html, body").animate({ scrollTop: $(e).offset().top }, 500).delay(500); }); setTimeout(function() { $('html, body').animate({ scrollTop: 0 } ...

automatically created button, form control named 'answer' that is not valid

Struggling with a challenge in attaching an event to a dynamically generated button. Despite conducting some research, most of the solutions suggest that this issue is typically related to a form control. However, in my scenario, the error "invalid form co ...

IE11 adds additional spacing around list elements

I am encountering a peculiar issue with how Internet Explorer 11 handles unordered lists, unlike other browsers. Below is a comparison of how the ul appears in IE11: And here is how it looks in Chrome and other browsers: .iconImgBA { max-width: 2.4r ...

Verifying StartDate and EndDate using AngularJS and Bootstrap Datepicker

My HTML Coding <form name="myForm"> <div class="row"> <div class="col-md-2"> <input data-ng-model="Data.StartDate" type="text" id="startDate" name="startDate" class="form-control" data-da ...

Positioning elements next to each other in jQuery on mouse over - while also addressing scrolling issues in a div

After tinkering with this interesting concept of mouseover combined with absolute positioning divs on a jsFiddle, I encountered some unexpected results. The code was inspired by a stackoverflow thread on positioning one element relative to another using j ...

Having trouble with centering my div in HTML and CSS

Coding Challenge .nav_bar { position: absolute; top: 0; width: 800px; height: 23px; display: inline-block; text-align: center; background-color: #0090bc; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; border: 2px solid #004D6F; -web ...