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

Parent container fails to center align when window is resized

When I resize my window to a smaller size, like that of a smartphone screen, the three inner divs (colored red, green, and blue - .left, .center, and .right) do not align in the center. Please refer to the screenshot attached for clarity. My goal is to ens ...

Concealing Website Elements with javascript based on class assignments

Despite my hesitation, I have to ask this question after unsuccessful searches in related articles. In my code, I have 7 nav links all with the same class. Due to the length of the HTML, I am looking for a way to hide contents until the link is clicked, an ...

Modify the indentation format in CSS/JS

When the Tab key is pressed in an HTML page and the tabbed link gets highlighted, is it feasible to customize the style of that highlight? ...

Creating a component that surpasses all others

I have a code snippet that contains styling information for two div elements. How can I ensure that my <div id="home"> appears below my <div id="navigate"? Any suggestions? #home { background-color: black; color: grey; text-align: c ...

Looking for a way to exclude both parents and children from a list of relatives? Want to ensure that the

I've been struggling to align these list elements with their counterparts, but they seem to automatically create a margin for their child elements. It is essential for these list items to maintain the position:relative attribute so that the #dropdown ...

Do you think it's achievable to modify the color using CSS's order attribute?

When I look at the code in Firefox's inspector, I notice this : element { order:35; } Can a color be assigned to it? I am customizing my year outlook calendar and have set a particular day to display in a different color. But when I click on the mo ...

Issues with Laravel 8's datatable scripts causing dysfunction

In my practice with the AdminBSB template, I am facing an issue where the Jquery datatable plugin JS is not functioning properly in my blade template. I aim to achieve a datatable layout similar to this example: https://i.sstatic.net/krfPl.jpg However, t ...

Using the class for jQuery validation as opposed to the name attribute

I am looking to implement form validation using the jquery validate plugin, but I am facing an issue with using the 'name' attribute in the html since it is also used by the server application. Specifically, I want to restrict the number of check ...

Guide on emphasizing a div when the page's validity is not true

Is there a way to highlight a specific div when the page.isvalid=false? I can display the error message on page load, but struggling to highlight the required control. I have a JavaScript function that applies an error class to the div, which works fine w ...

The two divs are positioned on top of one another, with the link in the bottom div being unclickable

I am trying to create a unique effect where a tile divides into two on hover, with each tile acting as an individual link. Additionally, I want the background color of the tiles to change on hover. To achieve this, I have stacked two divs (toptile and bot ...

Customized figcaption formatting separate from the surrounding text

Is there a way to add a "figcaption" with independent settings to images placed alongside paragraphs in HTML? I have the following code snippet, but I'm unsure if I am using the figcaption tag correctly: <p><figure><span class="image ...

Column Alignment Problem in Bootstrap

I'm currently working on a blog template project that resembles the design of this particular page However, I've encountered an issue with aligning the grids in a way that meets my requirements. To showcase my problem, I have shared my version o ...

What is the best way to incorporate a unique box shadow onto my svg image?

While I've seen a similar question here: How to add box-shadow to a svg path circle shape, I am struggling to grasp how the transition from box shadow characteristics to SVG drop shadow characteristics was achieved. (Especially given that SVG Drop sha ...

What is the mechanism behind the functionality of padding percentage?

HTML <div class='container'> <div class='boxContainer'> The text inside this box should be centered vertically </div> </div> CSS .container { position: relative; height: 300px; wid ...

Tips for eliminating any default white space visible between tags:

What is the best way to eliminate white space gaps between div tags and adjust pixel differences between them in HTML code? My current alignment is off and there are noticeable white spaces between div tags. I have tried using a reset link but it didn&apo ...

Using jQuery to create a flawless animation

I am currently working on an animation project, and I have shared my progress on jsfiddle. Below is the code snippet I have utilized: /* JavaScript: */ var app = function () { var self = this; var allBoxes = $('.box&apos ...

Learn how to use Angular2 or TypeScript to display 'unsubscribe' and 'subscribe' text on a toggle button

I'm working on a toggle button that initially displays the word subscribe on the thumb. When the toggle is disabled, I want it to show unsubscribe instead. Can someone please help me achieve this functionality? Here's the code snippet: <md-s ...

What causes custom CSS properties to be overridden by Material UI CSS class properties?

I encountered an issue while attempting to utilize an npm package containing a Typography element from Material UI. The code is authored by me. Upon integrating it into a project, I noticed that the typography's CSS class properties were overpowering ...

Stop SCSS from processing CSS variables in Angular-CLI

I am currently using Angular5 with sass v1.3.2. My goal is to dynamically change a color that is widely used in the scss files of my single page app without having to recompile new files. This color is globally defined in my _variables.css as: $brand: # ...

Activate a CSS button upon clicking and update the content within the div

In order to achieve the desired result of having menu CSS buttons change the content of a div when clicked, I have managed to do that successfully. However, a problem arises when clicking on the 2nd or 3rd button/link - it changes the div content, but as s ...