The ul class is not aligned with the website logo

My navigation menu items are not appearing inline with the logo on my website. I suspect it might be due to the size of the logo. I've attempted to adjust the width property of the #logo element, but it doesn't seem to be working...

Here is a visual of the issue: http://prntscr.com/p5aygy

Logo dimensions: 496px x 109

HTML



    <!--Navigation Menu-->
    <nav>
        <div id="logo"><img src="images/White.png"></div>
        <label for="drop" class="toggle">Menu</label>
        <input type="checkbox" id="drop"/>
        <ul class="menu">
            <li><a href="#">Home</a></li>
            <li><a href="#">Pricing</a></li>
            <li><a href="#">Faq</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </nav>

CSS FILE


nav {
    margin: 0;
    padding: 0;
    background-color: black;

}
#logo {
    display: block;
    float: left;
    padding: 10px 0 0 30px;
}
nav:after {
    content: "";
    display: table;
    clear: both;
}
nav ul {
    float: right;
    list-style: none;
    padding: 0;
    margin: 0;
}
nav ul li {
    display: inline-block;
    float: left;
}


@media (max-width:768px) {
    #logo {
        display: block;
        width:100%;
        text-align: center;
        float: none;
        padding: 20px 0 10px;
    }
    nav ul li {
        width: 100%;
    }
    .toggle + a, .menu {
        display: none;
}

}

Answer №1

It seems like the padding added by your CSS to the top of the logo through the #logo selector is causing the extra spacing. To remove this spacing, consider modifying the #logo selector lines as shown below:

#logo {
    display: block;
    float: left;
    padding: 0 0 0 30px;
}

Make the same adjustments for the media query line mentioned below:

@media (max-width:768px) {
    #logo {
        display: block;
        width: 100%;
        text-align: center;
        float: none;
        padding: 0 0 0 10px;
    }
}

Additionally, check if your logo image contains transparent space around the visible part. Improper image trimming can lead to unintended spacing issues.

If possible, share a link to the logo image file for further investigation to rule out this potential issue.

Answer №2

Consider including a margin-top of 10px on the UL section

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

Controller function failing to trigger

I'm new to asking questions, so if I've made a mistake, please let me know. I've searched for an answer here but couldn't find one. Any help would be greatly appreciated. I'm attempting to load a list of "Countries" using a contro ...

No children were located within the div element

Presently, I am attempting to disable an image for the initial element in each faqs div class in HTML. To achieve this, I am aiming to target the parent element of faqs and then navigate downwards to locate the initial list element using the following Java ...

Tips for incorporating a JavaScript script into local HTML code

I am facing an issue with my code on jsfiddle. It works perfectly there, but when I try to run it locally, it doesn't seem to work. I have checked the code multiple times and even downloaded the jQuery file to link it, but still no luck. I feel like i ...

Tips for adding information into a designated DIV using JQUERY

Having a bit of trouble with my JQUERY at the moment. Basically, I have this Facebook-style layout for displaying posts. Each post has an <input> box where members can leave comments. When a user presses <enter>, my jQuery (AJAX) will fetch th ...

Angular: "btn" class vanishes when the button is toggled

I am facing an issue with the button's class change functionality. I am using the [ngClass] directive to switch between Bootstrap classes for the button style. However, when I click the button, the "btn" class seems to disappear from the code. Instead ...

Elements contained within the enclosing div will not be visible

I'm currently working on a responsive webpage, and I've encountered a new issue that I can't seem to resolve. I've wrapped three separate divs within a parent div, but for some unknown reason, the child divs are not displaying. Can some ...

Tips on applying a border to an HTML tr

Imagine I have created a table like this: 1 Chailie 23 Joker Bass 2 Chailie 23 Joker Bass 3 Chailie 23 Joker Bass 4 Chailie 23 Joker Bass 5 Chailie 23 Joker Bass 6 Chailie 23 Joker Bass Now I wa ...

Displaying a single row of a PHP array in bold formatting

I have a MySQL query result showing user information and subjects they have chosen. I want to highlight one specific row by making it bold using PHP while keeping the rest as regular text. How can I achieve this? $resultSet = $db->query ("...my q ...

Attempting to trigger the timer to begin counting down upon accessing the webpage

Take a look at this example I put together in a fiddle: https://jsfiddle.net/r5yj99bs/1/ I'm aiming to kickstart as soon as the page loads, while still providing the option to pause/resume. Is there a way to show the remaining time as '5 minute ...

Utilize jQuery to set a cookie, then apply the bodyclass retrieved from the cookie upon page

I have a button that changes the body class to .blackout For this, I am utilizing js-cookie library to manage cookies. The code snippet associated with my button is shown below: <script> $('#boToggle').on('click', function(e) { ...

CSS selector for GTM trigger that is not specific to any particular element

I am attempting to develop a CSS selector that can target the specific entries within the page-top-menu: Header menu - Menu 1 DE #page-top-menu > div > div.menu-wrapper > ul > li.i39.dropdown.layer.item-type-1.catid-0eca5a6c6e53f281b9e0469ca3d ...

Effortlessly retrieving the id attribute from an HTML tag using jQuery

Currently, I am encountering an issue with a code snippet that is designed to extract the value from an HTML tag. While it successfully retrieves a single word like 'desk', it fails when attempting to do so for an ID consisting of two or more wor ...

Troubleshooting ASP.NET Content Page Error: jQuery Object Expected

Currently working on designing a personal ASP.NET Web page, I have encountered an issue with making a sticky div using jQuery. Despite all my other jQuery functions functioning properly, the sticky div seems to be causing trouble. stickydiv.js $(document ...

Organizing content on a webpage with specific pixel measurements

I have a div and am utilizing Bootstrap 5. I'd like to have the Description and Length elements on separate lines when the page width is <=1024px. <div class="col-3 col-md-4 col-lg-3"> <div class="card d- ...

Preserve unencoded HTML content as a string

Here is an example string: text = '&lt;div class="blue"&gt; &lt;p&gt;This is a sample text string' When I use <%= text.html_safe %> in my webpage, it displays correctly, but not when I try it in the console. If I attempt: ...

Load elements beforehand without displaying them using a div

In order to efficiently manipulate my Elements using jQuery and other methods, I am exploring the idea of preloading them all first. One approach I have considered is creating a div with CSS display set to none, and placing all the elements I need for my w ...

Present the value of an object within an array in an HTML format

I have organized an array containing information about different video games: let games = [{ title: 'Fortnite', price: 20, img: "./assets/images/Fortnite.jpg" }, { title: 'Valorant', price: 0, img: "./asse ...

What could be causing the issue of my p tag not being centered within both of my content divs?

I'm struggling to center the paragraphs within the divs with classes .content1 and .content2. Can anyone help me figure out why? Check out the demo here Here is the code: .content1 p, .content2 p { text-align: center; background-color: rgba ...

Creating a clickable link that dynamically updates based on the span and id values, and opens in a new browser tab

I am attempting to create a clickable URL that opens in a new window. The URL is being displayed and updated on my HTML page in the following manner: Python Code: def data_cb(): return jsonify(waiting=await_take_pic()) Javascript Code: jQuery(d ...

Unable to use jQuery to choose an item from a dropdown menu and reveal a hidden text box

Seeking assistance in displaying a paragraph with text and a textbox when a specific option is selected from the dropdown menu on my form. Previously used code for radio buttons, but encountering issues with this scenario. Any guidance would be greatly app ...