The container is accumulating excess margin

Here is the HTML code I am working with:

<!DOCTYPE html>
<html>
<head>
<meta charset="US-ASCII">
<link
    rel="stylesheet"
    type="text/css"
    href="css/index.css"
>
<title>Best company in the USA</title>
</head>

<body>
    <div class="menu">
        <h2>MENU</h2>
        <ul>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>

    <nav role="navigation">
        <div class="navWrap">
            <h2 class="navClose"></h2>
            <ul>
                <li><a href="somelink.com">Home</a></li>
                <li></li>
                <li><a href="somelink.com">About us</a></li>
                <li></li>
                <li><a href="somelink.com">Services</a></li>
                <li></li>
                <li><a href="somelink.com">Locations</a></li>
                <li></li>
                <li><a href="somelink.com">Contact Us</a></li>
                <li></li>
            </ul>
        </div>
    </nav>

    <div class="content">
        <section class="first"></section>
    </div>

</body>

</html>

This is my CSS code:

@CHARSET "US-ASCII";

* {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

::-moz-selection {
    background: none repeat scroll 0% 0% #D8262E;
}

/* More CSS code... */

Lastly, here is my jQuery:

$(document).ready(function () {

    windowHeight = 0.9 * $(window).innerHeight();
    $('.first').height(windowHeight);
    $(window).resize(function () {
        windowHeight = 0.9 * $(window).innerHeight();
        console.log("height: " + windowHeight);
    });

});

I have encountered a problem where there seems to be an extra margin of 8-10px on each side in the content class. One solution I found was to comment out the CSS in the .content class. However, I am looking for a better solution or insight into what might be causing this issue.

You can view a jsfiddle of this problem here: http://jsfiddle.net/kSdHU/ Thank you.

Answer №1

To fix the layout, try resetting your elements.

Simply include the following code:

* { margin: 0; padding: 0; }

See Demo

Answer №2

To prevent encountering any strange styling problems, I recommend utilizing a CSS reset. This will effectively reset the default styles of your browser to avoid unwanted element styling. Personally, my go-to is Eric Meyer's Reset, but there are numerous options available.

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

Discover the technique for combining three different text colors within one span element without resorting to the <font> tag

Is it possible to incorporate three different colors of text (details-red, Enter-blue, here-yellow) within a single span without utilizing the <font> tag? <span>Details Enter Here</span> ...

Struggling with retrieving the $id variable from the view in both the controller and the database through Ajax

While checking my view, I noticed that the variable $id is visible. However, when I send it through Ajax, it ends up as NULL in the database. The way I'm sending the variable $id from the view using Ajax is like this: $.ajax({ url:'{ ...

Tips for setting a specific height for an HTML table

For some reason, I can't seem to control the height of this table. I've set it to a maximum of 20px but all the rows are still showing. Here is the CSS: table { border:1px solid black; overflow:hidden; height:20px; max-height:20 ...

Leverage a nearby module with a local dependency

My current challenge involves integrating a local library into my project. I have been following two tutorials: how to create a library and how to consume a local library. Despite having a well-structured sample library with package.json and index.ts, I am ...

Attempting to modify a JSON file within a React application

I recently obtained a JSON file named 'DealerList.json' which I managed to import into my app using the following code snippet: import DealerList from './json/DealerList' let tasks = DealerList; The tasks now store the JSON data and I ...

Leveraging Python to authenticate on a website using JavaScript and secure HTTPS connection

I am looking to utilize python for logging into a website that utilizes javascript and https encryption. The specific site I'm referring to is: My goal is to create a python script that successfully logs in, with the intention of later translating th ...

Working with regular expressions on fieldsets in JavaScript jQuery

I'm facing an issue with a JavaScript regexp and I could really use some assistance. Currently, I have an ajax query result saved in a variable (in this case, a regexp) and I am trying to only match the content within the fieldset tag. Here is a sni ...

What is the best way to implement a gradual decrease in padding as the viewport resizes using JavaScript

My goal is to create a responsive design where the padding-left of my box gradually decreases as the website width changes. I want the decrease in padding to stop once it reaches 0. For instance, if the screen size changes by 1px, then the padding-left sh ...

Comparing Ajax methods: Which one reigns supreme?

I am seeking advice on the best approach to handle a series of Ajax insert, update, and delete operations. Which method is more effective? Creating individual methods for each function (e.g., delete_foo, insert_foo, update_foo, delete_bar, insert_bar, ...

How to achieve the functionality of multiple inheritance using Object.create()

Seeking insights on implementing multiple inheritance in JavaScript. Various methods exist, each with pros and cons. However, there lacks a comprehensive analysis of Object.create() presented in an understandable manner. After conducting experiments, I hav ...

How to Left Align Div Centered Within Another Div?

I've encountered an issue with centering icons in my HTML code. Despite trying to fix it myself, the icons always appear left-aligned. I would greatly appreciate any assistance from the helpful members of this community. It's likely a simple fix ...

Encountering an error stating "cloudinary.uploader is undefined" while attempting to delete media files from Cloudinary

I'm currently developing a web application using express and node.js. In my project, I'm utilizing cloudinary for uploading media files. While uploading and accessing media works smoothly, I'm encountering an issue with deleting images from ...

The href attribute not functioning properly in HTML code

I am experiencing an issue with linking a page where the href for Home and Login is not working. <div id="menu_wrapper"> <div id="container"> <ul class="menu" rel="sam1"> <li class="active"><a href="in ...

AngularJS and adding to an array in the routing process

I'm currently working on creating a contact list with two different views. One view displays all the contacts and includes an option to add a new contact, which is represented by a button rather than a space to input information directly. The other vi ...

Incorporate a new visual element with a texture in three.js

I'm struggling to apply a texture to a mesh and keep getting this error message: [.WebGLRenderingContext]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 1 It's frustrating not understanding ...

I am experiencing a JSON parse error while making an AJAX request after upgrading to Codeigniter 3.x. What could be the reason behind this

I am currently in the process of updating my Codeigniter framework from version 2.2.6 to 3.0.6, and unfortunately, this update has caused some previously working code to break. One specific error that I am encountering is "SyntaxError: JSON.parse: unexpect ...

What is the specific functionality of $find in the Microsoft Ajax library?

I'm feeling a bit puzzled about the functionality of $find from Microsoft Ajax. Does it simply retrieve a control like the $ operator in jQuery or JavaScript's getElementById? For example: $find('someControlId') Would this return th ...

Clicking the button becomes impossible after entering text and using `evaluateJavascript`

I am currently working on finding a solution to input the receipt number and click the 'Check Status' button on this specific website: After successfully entering the receipt number: document.getElementById('receipt_number').value = &a ...

Mapping nested values from a Typescript object to properties of a JSON object

Within the scope of a current project I am involved in, we have opted for utilizing the Angular toolset identified as formly to dynamically generate our forms. The present configuration of the form is hardcoded into a Typescript object denoted as mockForm ...

How can you transfer array elements to a new array using JavaScript?

I have a task to transform the fields of an array received from one server so that they can be understood by another server for upload. My approach involves first retrieving and displaying the original field names from the initial server's array to al ...