Arranging menu options directly below header image in CSS

As a beginner in this field, I have successfully created a header image and menu options saved as .png images.

However, I am facing an issue with aligning the menu images to the left of the screen instead of overlapping the edge of the logo.

To see the code, you can check out the fiddle: http://jsfiddle.net/lozjayne/xz99w/

Below is the code snippet (apologies if it's not that great)

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="C:\Users\Laura-Jayne\Documents\Crestel Website\cake\html\style.css" type="text/css">
<title>Cupcake Fairy</title>
</head>

<body>
<div id="header-container">
    <div id="header">
        <div id="logo">
        <a href="#"><img src="C:\Users\Laura-Jayne\Documents\Crestel Website\cake\images\logo.png" /></a>
        </div>

        <div id="topnav">
        <ul>
            <li><a href="#"><img src="C:\Users\Laura-Jayne\Documents\Crestel Website\cake\images\home.png" alt="home" /></a></li>
            <li><a href="#"><img src="C:\Users\Laura-Jayne\Documents\Crestel Website\cake\images\about.png" alt="about" /></a></li>
            <li><a href="#"><img src="C:\Users\Laura-Jayne\Documents\Crestel Website\cake\images\gallery.png" alt="gallery" /></a></li>
            <li><a href="#"><img src="C:\Users\Laura-Jayne\Documents\Crestel Website\cake\images\contact.png" alt="contact" /></a></li>
        </ul>
        </div>
    </div>
</div>

@charset "utf-8";

body {
margin: 0px;
padding: 0px;
}

#header-container {
width: 100%;
height: 204px;
background-color: #e7fc56;
}

#header {
background-image: url("C:\Users\Laura-Jayne\Documents\Crestel Website\cake\images\header.png");
background-repeat: no-repeat;
width: 1024px;
height: 204px;
margin: auto;
}

#logo{
float: left;
padding-top: 15px;
padding-left: 160px;
}



img {
border: none;
}

#topnav {

margin: auto;
height: 76px;
width: 1024px;
padding-top: 150px;
padding-left: 158px;
}



#topnav ul li
{
display: inline;
padding: 0px;
margin: 0px;
width: 100px;
}

#topnav ul a {
text-decoration: none;
background: #e7fc56
float: left;
text-align: left;
}

I hope someone can provide assistance with this issue. Thank you.

Answer №1

The current positioning of the menu is shifted towards the right side of the screen due to the presence of `padding-left`. By removing this, the alignment can be corrected to the left side.

View Updated Fiddle

#topnav {
    margin: auto;
    height: 100px;
    width: 1200px;
    padding-top: 200px;
}

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

tips on customizing buttons within form groups

I have set up two separate form-groups: My goal is to click on each button within each group and toggle its style from grey to green, and vice versa. However, when I click on a button, all buttons within the group turn grey except for the one that was cli ...

Switch to light mode upon clicking the toggle?

On the top left corner of this page, there's a toggle for "Light/Dark mode". Clicking on 'Light mode' smoothly transitions to dark mode without any issues. However, once it's in Dark mode and you try to switch back to 'light mode&a ...

What is the best way to align the <text> element within an SVG's parent <g> element?

I'm currently developing a booking tool that requires users to choose a desk on the map by clicking on it. Each desk is enclosed in its own group (<g>) with specific elements like <title>, <path>, and <text>. The issue I' ...

CSS: Is it possible to make a div even smaller than the invisible padding of a font?

link to code: http://jsfiddle.net/xVCrn/1/ (best viewed in chrome / webkit) I'm attempting to create a 1px margin for the red section within the dark button area, but I am struggling to adjust the height of the red part. =( The objective is to: ...

As I adjust the size of my browser, my website dynamically resizes to match

Recently, I created a website but encountered a bug where the website resizes when I resize my browser. This issue has been observed in Firefox (10.0.2), Chrome (16.0.912.77), and Opera (11.60) browsers. Interestingly, when testing other websites such as ...

The responsive navigation bar yielded an unforeseen outcome

Looking to create a responsive navigation bar similar to the one shown here My code successfully shows and hides the navigation items, but it's not updating the burger icon No console errors or warnings are present This is my HTML: <nav> ...

Selenium encountered an error: Element not found - Could not locate element: {"method":"CSS selector","selector":"*[data-test="email-input"]}

Recently, my application has been encountering an error when trying to log in through a web form. The issue seems to be with locating the email input field: "no such element: Unable to locate element: {"method": "css selector", "s ...

Exploring the process of updating the background color of a specific component in Angular

I'm currently working on a website that will feature alternating colors of white and black. However, I am facing an issue where I can only apply background color changes globally in the CSS file. Does anyone know how to address this problem? ...

JavaScript may not display height as anticipated

Currently, I am experimenting with JavaScript in order to achieve a website section that is 100% the height of the screen minus the "nav" bar. Imagine it as having two visible components - the first one being large and the second one small at the bottom. ...

The menu on the webpage in smartphone mode is infiltrating other divs on the page

Encountering an issue with the TwitterBootstrap CSS menu on this page when viewed on a smartphone: The div containing the menu does not resize its height, causing it to invade the content below when the "Menu" is clicked. I've been unable to find a ...

Conceal the background of the lower div when the top div is displayed

I am struggling to figure out how to achieve this, or if it can even be done: <body> has a background image <div parent> has a background image <div child></div> does not have a background </div> My goal is to make the chi ...

Applying personalized CSS to an element based on the condition of a child element in the previous sibling element

I am trying to apply styles to a span element only when a child element in a preceding sibling div element is active, which means a radio button has been checked. I am unable to modify the code and can only use CSS for this task. Any ideas on how to achi ...

Issues with CSS 3 compliance verification are not being resolved

Hey there, I'm currently working on implementing a multi-step form. However, I've run into an issue with adding CSS 3 validation to the form fields as it doesn't seem to be working correctly. Whenever I try to include CSS 3 validation, it sk ...

How can I create a box-shaped outline using Three.js?

As someone new to threejs, I have been trying to figure out how to render a transparent box around a symbol in my canvas. The box should only display a border and the width of this border should be customizable. Currently, I am using wireframe to create a ...

What are the steps to add border styles to the top and bottom rows in a tanstack expandable react table?

In my project, I am utilizing the combination of Material UI and React Table. Recently, I was asked to add an expandable row, and I successfully implemented that feature. Once a user expands the row, we display additional table rows based on the data. If ...

Develop a custom input field feature that utilizes both JavaScript and CSS

I really appreciate the feature that allows me to resize the textarea by simply clicking and dragging on the slanted lines in the lower right hand corner. However, I am looking for a way to apply CSS styles to text which is not possible with a textarea. ...

Utilizing JQuery for adjusting the CSS top property

I needed to overlay text on an image, so I used CSS for this purpose. However, as I incorporated Bootstrap and hesitated to include absolute positioning in the CSS file, I faced issues with centering the text when resizing the image. To tackle this problem ...

Animated CSS side panel

I'm currently working on creating an animation for a side menu. The animation works perfectly when I open the menu, but the problem arises when I try to animate it back closed. Is there a property that allows the animation to play in reverse when the ...

What is the best way to enable editing of a form when the edit button is clicked?

I have created a simple profile page where users can edit their profile information. I have placed a button at the end of the page. Initially, the form should be uneditable, but when the button is clicked, the form becomes editable. I attempted to use `dis ...

What is the best way to structure Vue.js components for optimal organization?

Imagine having an index page called index.vue consisting of various components like this: index.vue <template> <div> <component-1 /> <section class="section-1"> <div class="container section-container"> <com ...