Out of the blue, margin-top and marin-left suddenly appeared

Within my HTML file, I have a header containing an unordered list (ul) with list items (li) and anchor (a) elements for the menu.

/* ****** */
:root {
    --primary: #32a852;
    --white: #fafafa;
    --black: #000000;
    --lightgrey: #c7c7c7;

    --menu-items: #333333;
    --mobile-menu: #4a4a4a;
}

@import url('https://fonts.googleapis.com/css2?family=Open+Sans&family=Roboto&display=swap');

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.no-select {
    
}

/* Tags :) */
body {
    padding: 0;
    margin: 0;
    background: var(--primary);
}

/* Header */
.header {
    display: flex;
    background: var(--white);
    width: 100%;
    height: 0%;
    padding: 5px;
}

.menu-items {
    flex: 1;
    text-align: right;
    display: inline-block;
    list-style-type: none;
    transform: translateY(30%);
}

.menu-items li {
    display: inline-block;
    margin-right: 20px;
}

.menu-items li a {
    text-decoration: none;
    color: var(--menu-items);
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    font-size: 1.32rem;
}

.company-logo {
    width: 50px;
}

.menu-on-off {
    display: none;
    width: 50px;
}

@media (max-width: 530px) {
    .menu-on-off {
        display: inline-block;
        position: absolute;
        right: 3%;
    }
    .menu-items {
        text-align: left;
        padding: 10px;
        position: fixed;
        background: var(--mobile-menu);
        width: 100%;
        height: 100vh;
    }
    .menu-items li {
        margin-left: 10px;
        margin-top: 20px;
        display: block;
    }
    .menu-items li a {
        font-size: 1.5rem;
        color: var(--white);
    }
}

/* Header& */
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Реткинский Мультисад</title>
    <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="new.css" />
</head>
<body>
    <!-- Header -->
    <div class="header">
        <img src="img/logo.png" class="company-logo" alt="Logo">
        <div style="text-align: right;"><img src="img/menu.png" class="menu-on-off" alt="Menu" onclick="menutoggle();"></div>
        <ul class="menu-items">
            <li><a href="">Продукты</a></li>
            <li><a href="">Услуги</a></li>
            <li><a href="">Галерея</a></li>
            <li><a href="">Контакты</a></li>
        </ul>
    </div>
    
    <!-- JavaScript -->
    <script src="new.js"></script>
</body>
</html>

There are some issues with the menu design, specifically a small margin on the left and larger margin on top. These margins were not explicitly set in the code outside of the media query section. Check out this link for more details.

Wishing you a happy new year from Armenia! It's interesting to consider what specific details may be needed by Stack Overflow for assistance.

Answer №1

Alright, just made a few tweaks and it seems to be functioning as intended. Most of the adjustments relate to the positioning of elements.

/* ****** */
:root {
    --primary: #32a852;
    --white: #fafafa;
    --black: #000000;
    --lightgrey: #c7c7c7;

    --menu-items: #333333;
    --mobile-menu: #4a4a4a;
}

@import url('https://fonts.googleapis.com/css2?family=Open+Sans&family=Roboto&display=swap');

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.no-select {
    
}

/* Tags :) */
body {
    padding: 0;
    margin: 0;
    background: var(--primary);
}

/* Header */
.header {
    display: flex;
    background: var(--white);
    width: 100%;
    height: 0%;
    padding: 5px;
}

.menu-items {
    flex: 1;
    text-align: right;
    display: inline-block;
    list-style-type: none;
}

.menu-items li {
    display: inline-block;
    margin-right: 20px;
}

.menu-items li a {
    text-decoration: none;
    color: var(--menu-items);
    font-family: 'Roboto', sans-serif;
    font-weight: 500;
    font-size: 1.32rem;
}

.company-logo {
    width: 50px;
}

.menu-on-off {
    display: none;
    width: 50px;
}

@media (max-width: 530px) {
    .menu-on-off {
        display: inline-block;
        position: absolute;
        right: 3%;
    }
    .menu-items {
        text-align: left;
        padding: 10px;
        position: fixed;
        background: var(--mobile-menu);
        width: 100%;
        top: 28px;
        left: 0;
        right: 0;
    }
    .menu-items li {
        margin-left: 10px;
        margin-top: 20px;
        display: block;
    }
    .menu-items li a {
        font-size: 1.5rem;
        color: var(--white);
    }
}

/* Header& */
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Реткинский Мультисад</title>
    <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="new.css" />
</head>
<body>
    <!-- Header -->
    <div class="header">
        <img src="img/logo.png" class="company-logo" alt="Logo">
        <div style="text-align: right;"><img src="img/menu.png" class="menu-on-off" alt="Menu" onclick="menutoggle();"></div>
        <ul class="menu-items">
            <li><a href="">Продукты</a></li>
            <li><a href="">Услуги</a></li>
            <li><a href="">Галерея</a></li>
            <li><a href="">Контакты</a></li>
        </ul>
    </div>
    
    <!-- JavaScript -->
    <script src="new.js"></script>
</body>
</html>

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

The 3D hover effect is malfunctioning in the Firefox browser

I've been working on a 3D hover effect and my code is functioning properly in Opera and Chrome, but for some reason it's not working in Firefox. I've even attempted using vendor prefixes, but to no avail. The strange thing is that when I rem ...

Having trouble retrieving data from a contact form with php, js, and ajax?

I am facing an issue with my contact form on a website. I am unable to receive the filled fields from the contact form via email. Can someone please help me figure out what is wrong with the code or suggest an alternative solution? Any assistance in fixing ...

The functionality of Ajax loading content will fail when the link is already loaded

I am currently using an ajax script that dynamically replaces the content of #main with the contents of a loaded page based on the clicked link. For example, clicking on rddd would replace #main with the content of about.php. However, I encountered an is ...

Unable to choose the option from the modal that functions similarly to a drop-down menu

I need to choose a field that functions similarly to a dropdown box, but does not actually display as one. The select field reveals its values in a pop-up with values and sub-values that I need to select. Challenges : I'm struggling to locate the ob ...

Aligning an image alongside two separate blocks of text

I'm having trouble creating a header bar on my HTML page with a h1 and h2 element, along with an image positioned to the right of both. No matter what I try, the image keeps appearing below the other elements. I attempted using display:inline-block; b ...

Identify Bootstrap modal to modify destination of keypress input

I am working on a piece of code that detects keypress events and focuses input towards a searchbar with the id "search". $( document ).keypress(function() { $("#search").focus(); In addition, I have a bootstrap modal dialog containing input fields ...

Developing a variety of jQuery tabs

I am encountering an issue with my ASP.NET MVC page where dynamically created divs within a jQuery tab are not displaying subtabs as expected. Although the parent tabs are rendering correctly, the subtabs are not being created for some reason. The Razor ...

Override current website to display the mobile version

Few limitations to consider. Dealing with Sharepoint 2013, which can cause some issues from time to time. Hopefully won't affect the outcome. Unable to modify the viewport meta tag for the site. The website is a preexisting large site that was ...

What is the best way to fit the text into a DIV row as efficiently as possible?

Looking for a solution to prevent a span from dropping down to the next line when text is too long within a fixed width and height row. The row consists of three elements, two with fixed widths and the third containing a span and text. Constraints include ...

Is it possible to create this layout using Bootstrap 5? I want to stack spans, with one inside the container and one outside

Trying to achieve a specific design using Bootstrap 5.3. https://i.sstatic.net/STifm.jpg This design should be placed over the showcase, with the following code for the showcase displayed below: <div class="showcase d-flex flex-column"&g ...

CSS for Adjusting Parent Height Based on Child Content

I've been working on adjusting the height of the parent class to fit the child class perfectly without overflowing Here is a snippet from my CSS file: Parent &__video position: relative; width: 471px; background: red; border-radius: 12px ...

Receiving the result as well as encountering undefined initially during AJAX request

I have a dropdown menu, and when a user selects an option, an AJAX call is made to retrieve and display data based on the selected value. If the dropdown value is 2, it triggers the AJAX request. However, I am encountering two issues: https://i.sstatic.n ...

Struggling to align an image perfectly within a Bootstrap row

Need help centering an image vertically and horizontally in my code. I've tried various methods found online, including using img-fluid, img-thumbnail, and my-auto classes. Setting margin: 10% works fine, but auto does not work as expected. <div c ...

Developing Wordpress plugins involving images - path not found

I'm currently developing a WordPress plugin and encountering some issues with images. My plugin is located in wp-content/plugins/my-plugin/ directory, and within that, there's a folder named images/test.png - how can I properly reference this ima ...

What is the method for customizing the NavBar color using CSS?

Hi there! I recently came across a responsive multi-level menu that caught my eye. After copying the CSS and JavaScript exactly, I ended up with this NavBar. The issue I'm facing is changing the default color (which is green) to another color. Here&ap ...

The pseudo-element ::before did not function as expected in the CSS code

I attempted to utilize the ::before element in HTML directly. Below is my code: <ul class="clear toogled" style="height:188pxl"> <li tabindex="0" style="display: block;"> <label for="MAP-IA_1_1_OR_CB_1" aria-label="Filter by product"> :: ...

Unable to fetch the data from HTML input field using autocomplete feature of jQuery UI

I am facing an issue with my html autocomplete textbox. Whenever I try to enter an address like "New York" and click on the submit button, it does not retrieve the input value and returns no value. Test.aspx <!--Address--> <div class="form-g ...

Trigger the Onchange event following the completion of the AutoComplete process

I am attempting to implement Autocomplete and onchange event simultaneously. Specifically, I am looking to trigger the onchange event in an autocomplete textbox. When I type something in the textbox using the keyboard and then click outside of the textbox ...

jQuery performs perfectly in Chrome but encounters issues in IE9/IE8 and other older versions of Internet

I've implemented this lengthy jQuery script to enable dynamic dropdown loading and updating when selections are changed. However, I'm facing issues in Internet Explorer where the script loads the dropdowns initially but doesn't trigger oncha ...

Divs aligned horizontally with automatic height

I am facing a dilemma with two child divs placed side by side within a parent div. The height of each div is generated based on the viewport-size, making it unknown. The issue arises in the left div where an image needs to be resized to match the height o ...