The final item in the navigation bar is off-center

After centering all text within the li tags, the last one appears to be slightly closer to the bottom. Below is the code snippet along with an image:

    *{
    margin:0;
    padding:0;
    box-sizing:border-box}
    
    #hamburgerClick{
        display:block;
           width:65px;
      height:65px;
      position: fixed;
      overflow: hidden;
      top:50px;
      left:50px;
      cursor: pointer;
      z-index:9999999999999;
    }
    header h1{
        width: 100%;
        text-align:center;
        color:white;
        background: #252525;
    }
    header{
        flex-direction: column;
        padding:0;
    }
    header ul{
        flex-direction: column;
        height:100%;
        width:100%;
        height:100vh;

         display:flex;
    list-style:none;
    transition: ease .8s;
    justify-content: space-between;
    }

    .ultog{
        transform: translateX(0%);
    }
    header ul li{
          text-align:center;
    width:6em;
    font-size: 1.1rem;
        box-sizing: border-box;
        width:100%;
        height: 100vh;
        background:#131313;
        color:white;
        border-top: 2px solid #252525;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size:2em;
        cursor: pointer;
        margin:0;

    }
    header ul li:nth-child(1){
        border: none;
    }
    <div id="hamburgerClick">
        <div id="hamburger"></div>
        <div id="hamburger2"></div>
        <div id="hamburger3"></div>

    </div>
    <header id="header">
        <h1>Photo21</h1>
        <ul>
            <li>Home</li>
            <li>Products</li>
            <li>Career</li>
            <li>About us</li>
            <li>Contact</li>
        </ul>
    </header>

Answer №1

It seems that the issue lies in the height of your ul element being set to 100vh (the entire window), while having an h1 element on top of it. This results in the total height being the sum of the h1 and 100vh.

A potential solution would be to assign a fixed height to the h1 (for instance, 40px) and then adjust the ul with the following CSS:

height: calc(100vh - 40px);

You can view a snippet below demonstrating this fix (please open it in full page for accurate display):

*{
    margin:0;
    padding:0;
    box-sizing:border-box}
    
    #hamburgerClick{
        display:block;
           width:65px;
      height:65px;
      position: fixed;
      overflow: hidden;
      top:50px;
      left:50px;
      cursor: pointer;
      z-index:9999999999999;
    }
    header h1{
        width: 100%;
        text-align:center;
        height: 40px;
        color:white;
        background: #252525;
    }
    header{
        flex-direction: column;
        padding:0;
    }
    header ul{
        flex-direction: column;
        height:100%;
        width:100%;
        height:calc(100vh - 40px);

         display:flex;
    list-style:none;
    transition: ease .8s;
    justify-content: space-between;
    }

    .ultog{
        transform: translateX(0%);
    }
    header ul li{
          text-align:center;
    width:6em;
    font-size: 1.1rem;
        box-sizing: border-box;
        width:100%;
        height: 100vh;
        background:#131313;
        color:white;
        border-top: 2px solid #252525;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size:2em;
        cursor: pointer;
        margin:0;

    }
    header ul li:nth-child(1){
        border: none;
    }
<div id="hamburgerClick">
        <div id="hamburger"></div>
        <div id="hamburger2"></div>
        <div id="hamburger3"></div>

    </div>
    <header id="header">
        <h1>Photo21</h1>
        <ul>
            <li>Home</li>
            <li>Products</li>
            <li>Career</li>
            <li>About us</li>
            <li>Contact</li>
        </ul>
    </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

React Navigation Item Toolbar Misplacement

I've been trying to align the navigation item with the logo on the same line within the toolbar, but I'm facing an issue where they keep appearing in different rows. To see the error for yourself, check out the code sandbox here. This is how I s ...

Altering the character by striking a key

I have a canvas with custom styling. In the center of the canvas is a single letter. Please see the code below for reference. The goal is to change the displayed letter by pressing a key on the keyboard. For instance: Letter A is centered in the canvas: P ...

Align the inner container in the outer container-fluid

I'm struggling to center a container inside a container-fluid. Any suggestions on how to make it work? /* Setup Buttons Specific Styling */ .setup-bg { background: url("https://image.ibb.co/geAGqy/setupbtns_bg.png"); background-repeat: no-repea ...

Mastering the Art of Harnessing External Templates in Meteor Mantra

I have been diving into the Mantra style guide () in order to integrate it with meteor. What confuses me is determining the "right" approach for using external templates with meteor and mantra. Specifically, I'm unsure about handling CSS and JS files. ...

Utilizing CSS to incorporate percentage points

Currently, I am facing a challenge in implementing a vertical line with percentage marks. It needs to be positioned relative to the percentage bar, just like how it appears in the screenshot below: https://i.stack.imgur.com/CNWUV.png I attempted a basic ...

Combining keyframe properties in a more efficient way using less code

While attempting to develop a LESS mixin for CSS3 keyframes, I encountered the typical way of chaining IDs and classes: #idOne, #idTwo, .classOne, .classTwo { ... } Nothing groundbreaking there. What I'm currently working on is crafting the foll ...

What is causing my animation to jump when using the Web Animation API reverse() function?

I've come across various sources stating that when you call reverse() while an animation is playing, it should have the same effect as setting playbackRate to -1. However, in my case, using reverse() makes my animation behave erratically and jump arou ...

Footer that is adhered to the bottom of the page with a

Can a sticky footer with a transparent background be achieved without a content background (.wrapper) underneath it? I found this resource: ...

I'm unable to adjust the font size of the final h3 element

I'm currently designing a webpage with various titles, but I've encountered an issue. I am unable to adjust the font size of the last h3 title without affecting the rest of the titles. I'm curious as to why this is happening and how I can re ...

The class is failing to be applied to the parent div that holds an id starting with the letter x

I have been attempting to assign a class to the parent container when the child element has the 'hidden' class. If not, then a different class should be added. function tagMissions() { if ($('span[id^="mission_participant_new"]').h ...

Adjust the minimum height and width when resizing the window

Apologies in advance if this has already been addressed, but I have tried solutions from other sources without success. My Objective: I aim to set the minimum height and width of a div based on the current dimensions of the document. This should trigger ...

Spinning with animation in jQuery

Greetings! I am in the process of creating a popup box that will appear upon clicking the Login button. My aim is to produce a popup box with a rotating effect, however, my attempts have not been successful so far. You can view the code snippet on JsFidd ...

Employ CSS flexbox and/or JavaScript for creating a customizable webpage

I am in the process of developing a basic IDE for an educational programming language that has similarities to Karel the Dog. One major issue I am encountering is creating the foundation HTML page. The IDE consists of 4 main areas: Toolbox (contains but ...

The Bootstrap button is experiencing difficulties with resizing

When utilizing the bootstrap CDN in conjunction with another bootstrap CSS example file located in the static directory, I encountered an issue while attempting to create a file input and submit button for a form. Despite my efforts, I was unable to adjust ...

The functionality of min-height in CSS seems to be malfunctioning

One of my HTML elements has a parent with the ID #out, and a child with the ID #in. The parent is positioned absolutely, with a minimum height of 100%. It seems to be functioning correctly in most browsers, except when I also set the child's min-heigh ...

"Placing drop-down animations in just the right spot

I'm currently working on adjusting the dropdown behavior for thumbnails when hovering over them. I want the drop-down to appear beneath the 'Caption Title' instead of above the image, but so far my CSS adjustments haven't been successfu ...

Floating CSS containers

Apologies for not including a picture. You can view the design I am trying to achieve here. I am attempting to create two boxes with a third box below them, and another box on the right side of the layout. All enclosed within a larger container. Everythin ...

Streamlined Boilerplate to Kickstart Your Project

Can anyone suggest a well-crafted boilerplate .less file to kickstart a new project? I'm looking for a comprehensive .less file that includes: CSS Resets styles CSS Normalizer styles CSS3 Helpers (box radius, gradients, box shadow, transition) Basic ...

Combining two images using HTML and CSS resulted in conflicts when attempting to overlay any additional elements

I have managed to overlay two images successfully, but I am experiencing conflicts when trying to do the same with other div images. Here is the code on jsfiddle: https://jsfiddle.net/cLew1t2v/ and here is the code snippet: <div> <div style ...

`Ineffectiveness of CSS media query for font-size adjustment in HTML selector`

I recently implemented the 62.5% trick to adjust my font-size for various screen sizes. However, I noticed that on larger screens, the text appears too small. To address this, I tried increasing the font-size to 80% using a min-width media query. Unfortuna ...