Centralized Title / Side-aligned Menu

Good day, I am in need of assistance with a menu layout for my website. My goal is to have the title centered with the menu flexed out to the sides, but I'm encountering some issues. The colors included are just for testing purposes and will be updated later on. Below is the code snippet. I trust you can grasp the issue and offer your expertise.

HTML

@import url('https://fonts.googleapis.com/css?family=Pacifico');

body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  vertical-align: center;
}

/* ----- HEADER -----*/

body header {
  width: 100%;
  height: 90px;
  margin: 0;
  padding: 0;
  background-color: black;
  border-bottom: 2px solid #FFFFFF;
  box-shadow: 0px 8px 8px 0px rgba(215,223,237,.8);
}

/* ----- HEADER TITLE ----- */

body header .TITLE {
  line-height: 90px;
  width: 20%;
  background-color: aqua;
  position: absolute;
  left: 40%;
  right: 40%; 
  text-align: center;
}

body header .TITLE h1 {
  margin: 0;
  font-family: 'Pacifico', cursive;
  font-size: 45px;
  color: orange;
}

/* ----- HEADER MENU LEFT ----- */

body header .HEADERMENULEFT {
  float: left;
}

body header .HEADERMENULEFT ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;  
}

body header .HEADERMENULEFT ul li {    
  flex-grow: 1; 
  float: right;                             
  text-align: center;
  width: 100%;
}

body header .HEADERMENULEFT ul li a {
  color: white;
  text-decoration: none;
  display: block; 

/*line-height: 35px;
margin-top: 22px;
background-color: #90afc5;
height: 35px;
margin-left: 50px;
margin-right: 50px;
border-radius: 50px;*/
}

/* ----- HEADER MENU LEFT ----- */

/* ----- HEADER MENU RIGHT ----- */

body header .HEADERMENURIGHT {
  float: right;
}

body header .HEADERMENURIGHT ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;  
}

body header .HEADERMENURIGHT ul li {    
  flex-grow: 1; 
  float: right;                             
  text-align: center;
  width: 100%;
}

body header .HEADERMENURIGHT ul li a {
  color: white;
  text-decoration: none;
  display: block; 

/*line-height: 35px;
margin-top: 22px;
background-color: #90afc5;
height: 35px;
margin-left: 50px;
margin-right: 50px;
border-radius: 50px;*/
}

/* ----- HEADER MENU RIGHT ----- */

/* ----- HEADER ----- */
<header>
    <div class="TITLE">
        <h1>MyWeb</h1>
    </div>
    <div class="HEADERMENULEFT">
        <ul>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
        </ul>
    </div>
    <div class="HEADERMENURIGHT">
        <ul>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
        </ul>
    </div>
</header>

Answer №1

Create a Title with Center Alignment and Left-Right Menu

@import url('https://fonts.googleapis.com/css?family=Pacifico');

body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  vertical-align: center;
}

/* ----- HEADER -----*/

body header {
  width: 100%;
  height: 90px;
  margin: 0;
  padding: 0;
  background-color: black;
  border-bottom: 2px solid #FFFFFF;
  box-shadow: 0px 8px 8px 0px rgba(215,223,237,.8);
}

/* ----- HEADER TITLE ----- */

body header .TITLE {
  line-height: 90px;
  background-color: aqua;
  float: left;
  text-align: center;
  width:20%;
}

body header .TITLE h1 {
  margin: 0;
  font-family: 'Pacifico', cursive;
  font-size: 45px;
  color: orange;
}

/* ----- HEADER TITLE ----- */

/* ----- HEADER MENU LEFT ----- */

body header .HEADERMENULEFT {
  float: left;
  width:40%;
}

body header .HEADERMENULEFT ul {
  margin: 0;
  padding: 35px 10px;
  list-style: none;
  display: flex;  
}

body header .HEADERMENULEFT ul li {    
  flex-grow: 1; 
  float: right;                             
  text-align: center;
  width: 100%;
}

body header .HEADERMENULEFT ul li a {
  color: white;
  text-decoration: none;
  display: block; 

/*line-height: 35px;
margin-top: 22px;
background-color: #90afc5;
height: 35px;
margin-left: 50px;
margin-right: 50px;
border-radius: 50px;*/
}

/* ----- HEADER MENU LEFT ----- */

/* ----- HEADER MENU RIGHT ----- */

body header .HEADERMENURIGHT {
   float: right;
   width:40%;
}

body header .HEADERMENURIGHT ul {
  margin: 0;
  padding: 35px 10px;
  list-style: none;
  display: flex;  
}

body header .HEADERMENURIGHT ul li {    
  flex-grow: 1; 
  float: right;                             
  text-align: center;
  width: 100%;
}

body header .HEADERMENURIGHT ul li a {
  color: white;
  text-decoration: none;
  display: block; 

/*line-height: 35px;
margin-top: 22px;
background-color: #90afc5;
height: 35px;
margin-left: 50px;
margin-right: 50px;
border-radius: 50px;*/
}
<header>

    <div class="HEADERMENULEFT">
        <ul>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
        </ul>
    </div>
     <div class="TITLE">
        <h1>MyWeb</h1>
    </div>
    <div class="HEADERMENURIGHT">
        <ul>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
            <li><div class="BORDER"><a href="#">TEST</a></div></li>
        </ul>
    </div>
    
</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

Creating an animated transition for an element's height with CSS

I need to animate the height of a div that doesn't have a specified height. Using max-height isn't an option due to multiple potential height amounts. I attempted adding transition: height 0.2s ease to the div, but it didn't work as expecte ...

Ways to create a clickable anchor tag without using any text

I am currently designing my own website and incorporating links to various social media platforms using icons. However, I am facing an issue where the links are not clickable. For a detailed look at my problem, you can refer to this JSFiddle: http://jsfid ...

What methods can I use to achieve a stylish and responsive design for my images?

I have been encountering difficulties styling the images for my website. Despite multiple attempts, I am unable to apply CSS properties such as border-radius and responsive design to the images on my page. The images load fine, but they do not seem to acce ...

What is the standard way elements are displayed within a box that is positioned absolutely?

My current setup involves setting <body> to be absolutely positioned in order to fill the entire viewport without needing to specify a height: body { width: 100%; margin: 0; padding: 0; position: absolute; top:0; right:0; bottom: ...

IE6 disrupts stored layouts

I've encountered a strange issue with my design in IE6. It loads perfectly at first, but after reloading it a couple of times, everything suddenly collapses. The strange part is that when I upload an updated version, it fixes the issue, only to break ...

The functionality of the Bootstrap carousel for moving to the next and previous images is malfunctioning, as it only

The carousel on my website is not functioning properly. It only displays the first image and does not slide to the next pictures as it should. Here is the code snippet for the carousel: <body> </nav> <div id="carousel1" class="carousel slid ...

How can I determine the remaining amount of scroll left in my HTML document?

Is there a method to determine how many pixels of scroll remain on the page when the scrollbar is set at a specific position? I am currently utilizing jQuery's scrollLeft feature, which can be found here: http://api.jquery.com/scrollLeft/. I want to ...

Showing a div with 2 unique data attributes - such as displaying Currency and Quantity

My E-Commerce website is created using HTML, JavaScript, and PHP. On the product details page, users can add products to their cart, so I show the total cart value. I need the total amount displayed in a decimal number format (10,2). Currently, when a u ...

What is the best way to add a right-hand side navigation bar without blocking the scrollbar from view?

Take a look at this webpage: I am designing a website that includes a header, a footer, and a central container with left and right navigation bars surrounding a content area. However, I want the scrollbar for the content to appear on the right side of th ...

Using Conditional Tags for CSS Display

I'm working on implementing Conditional Tags to toggle a CSS class on or off based on the current displayed page. However, I'm running into an issue where the code isn't executing properly. There might be a syntax or logic error causing the ...

Search field in DataTables appears to be misaligned

I'm in the process of developing a small website using JSP and DataTables (currently only for the first table). Here's what I have so far: As you can observe, there seems to be an alignment issue with the search field position. I'm n ...

Guide to linking a label to a checkbox without utilizing the "for=id" method

Below is the code snippet I am currently working with: <li><input type="checkbox" id="checkboxThree" value="Alergia3" ><label for="checkboxThree">Alergia 1</label></li> <li><inp ...

Elements not following percentage in top positioning

I am facing an issue with resizing containers on my webpage. Despite using position: relative for everything, I am unable to properly adjust the size of the top containers using percentages. Any assistance would be greatly appreciated! ...

What is the specified height for the AppBar and Toolbar components in Material-UI?

I'm trying to figure out the exact height being used in this scenario: <AppBar position="static"> <Toolbar> because I'll need that information for a calculation in another component. My current assumption is that it's 64px, b ...

How can I overlay text on top of an image?

I want to create a design where half of the text overflows and overlays the image on the right side. How can I achieve this using a Grid item? I've tried using "absolute", "relative", and "z-index" positions, but they don't seem to work in the MU ...

``There seems to be a problem with the radio buttons where the selection disappears when

I'm facing an issue with a radio button group I created. It's functioning properly, but the selection disappears when clicked outside of the radio button. Can someone assist me in resolving this problem? Here is the link to the jsfiddle for refer ...

Developing my React application with Material UI. The fonts I've implemented don't appear consistent on Mac operating systems

Why does the font change in Mac and iOS platforms, and how can I ensure consistency across all devices? Here is an excerpt from my index.css file: body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto&apos ...

Excess space appearing to the right of the text box in Internet Explorer 9 standards mode and Google Chrome

Looking for help on how to eliminate the space between the right side of an input textbox and a red border? Check out these examples: IE: http://jsfiddle.net/fQHGA/ <div style="float:left;border:1px solid red"> <label style="float:left">a ...

Guide to generating customized CSS styles on-the-fly in Vue (similar to Angular's dynamic styling capabilities)

When working with Angular, we have the capability to dynamically set CSS properties. For example: <style ng-if="color"> .theme-color { color: {{color}}; } .theme-background-color { background-color: {{color}}; } .theme-border-color { border-color: { ...

Customize arrow direction in AntDVue ant-collapse using simple CSS styling

Is there a way to customize the arrow directions in ant-collapse vue? I recently faced an issue where I couldn't change the arrow directions without using !important (which I try to avoid). Fortunately, we found a workaround for this problem at my wo ...