Click on the logo to return to the home page

Logo Link Causing Menu Alignment Issue

After setting the logo as a link, the menu unexpectedly shifts to the right. Upon inspecting the menu element, it appears that there is an additional hidden menu link on the left side leading to index.html. Can anyone shed light on the possible cause of this issue?

#logo {
  height: 64px;
  position: absolute;
  left: 20px;
}

#menu {
  display: flex;
  flex-direction: row;
  justify-content: center;
}

nav {
  width: 100%;
  background-color: #000000;
  height: 64px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}

nav a {
  text-align: center;
  font-size: 25px;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100px;
  color: white;
  text-decoration: none;
  transition: .9s;
}

nav a:hover {
  background-color: orange;
  transition: .9s;
}
<nav>
  <div>
    <a href="index.html"><img id="logo" src="https://via.placeholder.com/400x400.jpg" alt=""></a>
  </div>
  <div id="menu">
    <a href=index.html>Home</a>
    <a href=index.html>About</a>
    <a href=index.html>Contact</a>
  </div>
</nav>

Answer №1

Update the css nav a to nav #menu a- Hopefully this resolves the styling issue.

#logo {
  height: 64px;
  position: absolute;
  left: 20px;
}

#menu {
  display: flex;
  flex-direction: row;
  justify-content: center;
}

nav {
  width: 100%;
  background-color: #000000;
  height: 64px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}

nav #menu a {
  text-align: center;
  font-size: 25px;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100px;
  color: white;
  text-decoration: none;
  transition: .9s;
}

nav a:hover {
  background-color: orange;
  transition: .9s;
}
<nav>
  <div>
    <a href="index.html"><img id="logo" src="https://via.placeholder.com/400x400.jpg" alt=""></a>
  </div>
  <div id="menu">
    <a href=index.html>Home</a>
    <a href=index.html>About</a>
    <a href=index.html>Contact</a>
  </div>
</nav>

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

Unique rephrased text: "Amongst a backdrop devoid of white,

In a div with a colored background, I noticed that adding an input element results in an unsightly border. <div class="input-group"> <input type="search" style="height:30px;"> </div> Is there a way to remove this border? ...

Use CSS to make the margin of one div the same width as another div

There are two classes that control the sidebar layout: .w-sidebar { width: 250px; min-width: 250px; max-width: 250px; } .row.collapse { margin-left: -250px; left: 0; } In order for the second class to function properly, the margin-le ...

A guide to resolving the issue of spacing out three adjacent elements in HTML/CSS

As I work on creating my personal website, I have encountered an issue with three elements that are supposed to be side-by-side. My desired structure is depicted in this link: However, the middle element is not responding to margin adjustments as expected ...

how to use AngularJS filter and ng-options to format specific options as bold in a select dropdown

I am currently utilizing AngularJS ng-options to populate specific select elements. I am interested in bolding and disabling certain options. Despite trying to achieve this using the filter along with ng-options, I have been unsuccessful so far. While I ca ...

A step-by-step guide on how to display a specified amount of images in the center of

I'm currently working with a div that displays images dynamically loaded from a database, ranging from 1 to 5 images. The number of images may vary each time, and I need assistance in centering these images inside the div regardless of their quantity. ...

Modify the location of the input using jQuery

Hey there, I've got this snippet of HTML code: <div class='moves'> <div class='element'><input type='text' value='55' /></div> <input class='top' type='text&apo ...

Ensuring XHTML W3C Compliance with multiple details in src attribute

We are currently working on a unique image carousel feature for our website. This carousel will display clickable thumbnails that, when clicked, will show the full-size image. In order to make this work, we need to include both URLs in the HTML code. Howev ...

What is the best way to align the content of a <ul> in the center while keeping the text left-aligned and setting a max-width

UPDATE: Including an image for better visualization: [![Check out the image link][1]][1] To understand more clearly, refer to this fiddle: https://jsfiddle.net/c7jazc9z/2/ Currently, I have a list with items aligned to the left. The goal is to center th ...

Ensure that the HTML image and text are positioned side by side, with the text appearing alongside the picture rather than below

Looking for a way to keep the text aligned to the right of an image, regardless of length? Check out this exercise: https://www.example.com/css/exercise-1 Is there a method to maintain the text layout next to an image while accommodating varying amounts o ...

Alignment problem

In my design, I have a toolbar with flex display and I am trying to center my span element within it. However, I seem to be missing something in the CSS. CSS .toolbar { position: absolute; top: 0; left: 0; right: 0; height: 60px; d ...

What is the best way to align text and an arrow on the same line, with the text centered and the arrow positioned on the

.down { transform: rotate(45deg); -webkit-transform: rotate(45deg); } .arrow { border: solid black; border-width: 0 3px 3px 0; display: inline-block; padding: 30px; } <p>Down arrow: <i class="arrow down"></i></p> Looking to ...

Can child elements be centered using their pseudo-elements using CSS alone?

Consider the code snippet below: <div class="example-container"> <p class="example">a</p> <p class="example">bbb</p> <p class="example">cc</p> </div> and the cor ...

The image sits on the edge of the container, not fully contained

.sub2 { background-color: #FFFFBF; margin-top: 30px; height: 410px; width: 100%; } h1.sub2 { font: bold 100px american captain; text-decoration: underline; float: right; } p.sub2- { font: italic 25px american captain; margin-top: -300px; ...

Can someone please explain how I can extract and display information from a database in separate text boxes using Angular?

Working with two textboxes named AuthorizeRep1Fname and AuthorizeRep1Lname, I am combining them in typescript before storing them as AuthorizeRep1Name in the database. Refer to the image below for the result. This process is used to register and merge the ...

Creating a Sudoku puzzle grid with HTML and CSS - a step-by-step guide

Apologies for the basic inquiry, but I have created a sudoku grid with the following structure. Modified(Using Tables): <table id="grid" border="1" style="border-collapse: collapse;"> <tr class="row"> ...

Tips for utilizing an event listener for a submission button

I am encountering a problem with this event listener. I attempted to add an event listener to the submit button, but it seems to be inactive. I can't figure out what mistake I have made! Here is my code: const form = document.getElementById("form") ...

Ways to update a specific div upon clicking an image

Is there a way to refresh a div using an image click? I have an image with the id 'sellhide' and another div with the id 'sellChart'. Below is the code: <div class="col-xs-12 col-lg-6 col-sm-6 col-md-6 index_table_three" id="sellCha ...

Styling a component next to another using CSS

Struggling with a simple question here. I'm experimenting with HTML and CSS, trying to create a page with a central content box flanked by two arrow images on each side. While the concept isn't too difficult, I'm running into issues with usi ...

What is the best way to add 1 to a number every second with javascript?

My code seems to be functioning correctly, but I'm having trouble setting the delay and stopping the increment after a certain interval. Can someone please assist me with this? Javascript: $(document).ready(function() { var number = parseInt($(& ...

Div element remains fixed in width while zooming in

I'm encountering an issue with a centered div, where the width is set to 50% and the max-width is set to 100%. When I zoom in, the width remains constant but the height increases. Despite setting the max-width to 100%, why does this occur? And most im ...