The entire screen is filled with a background image, but there's an odd margin that seems

I created a div to use an image as a background that covers the entire screen. However, there seems to be a mysterious margin that I can't seem to remove.

After examining the code, I couldn't find any indication that I had configured these margins. When I set the position to fixed in the CSS class for the background, the image appears like this:

https://i.sstatic.net/YQ6uI.jpg

But when I don't set the position to "fixed," it looks like this:

https://i.sstatic.net/K10bl.png

app.component.html

<main>
    <router-outlet></router-outlet>
</main>
login.component.html

<div class="back">

<!-- form content here -->

</div>
login.component.css

.form {
  background-color: transparent;
  border: #2196F3;
  padding: auto;
  margin: auto;
  justify-content: center;
  width: 50%;
  display: block;
  height: 50%;
  text-align: center;
  clear: both;

}

.back {
  background: url("../../../assets/background_paper.jpg")  no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  height: 100%;
  width: 100%;
  position: fixed;
}

.container {
  padding: 16px;
  width: 70%;
  margin: 0 auto;
  text-align: center;
}
                                        
.loginbutton {
  background: cornflowerblue;
  opacity: 0.8;
  border-radius: 10%;
  color: black;
}

Note: The inline styles will be removed later on.

Answer №1

After some investigation, I discovered that adjusting the margin to -8px resolved the issue effortlessly. Upon inspecting with Chrome's developer tools, I identified an 8px margin set on the HTML element that was not explicitly declared in the code. Appreciate the helpful insights and responses provided.

Answer №2

If you opt not to implement a reset style sheet like normalize or Eric Meyers Reset, it will be necessary for you to overwrite the default settings of the browser.

body {
  margin: 0;
}

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 for aligning navigation bar items to the right side

Seeking help with positioning the logo on the left and navigation items on the right using Bootstrap classes, while maintaining responsiveness. Click here for sample image 1 Check out the navbar layout <!-- Logo --> <a class="nav ...

TypeScript: Retrieve the data type of the provided object

Is there a way to create a function that receives a callback and returns the object returned by that callback? Here's an example of what I'm trying to achieve: const my_object = my_function<A extends string, B extends boolean> ("my_o ...

What could be the reason why the keypress event doesn't seem to be functioning properly on

Currently, I am utilizing Angular and the Ionic framework. Here is a snippet of the HTML code that I have written: <div><ion-input type="text" id="phoneNumber" [(ngModel)]="phoneNumber" (keypress)="phoneNumericCh ...

search engine optimized for easy input via keyboard

I have successfully incorporated AJAX search functionality into my project, inspired by this example here. The unique feature of this implementation is the ability to navigate through search results using the TAB key. The structure of my search results tab ...

The intl-tel-input dropdown feature is malfunctioning on mobile browsers

Currently, I have integrated the intl-tel-input library into my project for selecting international telephone numbers from a dropdown menu. https://i.sstatic.net/vPfpd.png While accessing the application on a web browser, the country flags display correc ...

tables that are intertwined

There are three tables on my page and they are all overlapping. Is there a way to prevent this overlap? Check out this link <table id="inventoryTable" class="table dataTable" aria-describedby="inventoryTable_info"> <thead& ...

Containers do not line up properly with each other. Adjusting the width leads to unexpected consequences

As someone who is new to HTML and CSS, I am facing a challenge with aligning the items within a navigation bar on my website. The list serves as a navigation bar and is contained inside the "inner header" div. While I was able to align the entire "nav" con ...

Angular directive: Changing image background dynamically when hovered upon

From the screenshot provided, it is clear that there is a background image for the page and two thumbnails positioned below the text. The objective is to dynamically change the background image of the page to match the thumbnail image when the mouse hovers ...

Should the element be scrolled beyond a fixed-positioned element

Is there a way to determine if an element is scrolled behind another element that is fixed at the top? I am looking to trigger some javascript when an element is positioned below a fixed element and every height or scrollTop thereafter. I am attempting t ...

Tips for combining multiple fields into a single variable in PHP

When I click the submit button, the image source does not show any result but the image color is displayed. Any help would be greatly appreciated. <div class="form-group"> <input type="file" name="images[source][]" class="form-control input-l ...

Tips for customizing the appearance of a Bootstrap toggle switch

I'm struggling to customize my bootstrap toggle button. No matter what I try, I can't seem to make any styling changes take effect. All I really need to do is increase the width of the button, but even that seems impossible. Here's a link t ...

"Canvas element's getContext method returning both WebGL2RenderingContext and RenderingContext - a conundrum for

Currently diving into typescript and facing a puzzling situation. I am attempting to check if the browser supports webgl. The detection process involves creating a canvas object on the document and obtaining the context to determine if it is "webgl" or "ex ...

Is it time to go back to the parent selector using the ampersand symbol?

I recently started using Less for writing CSS, and it has definitely been a time-saver for me. However, I have encountered a small issue with my code: <a href="#" class="btn-black-bg btn-right-skew">largest fight gym in Australia</a> Less .b ...

The HTML classes mentioned do not appear to be present in the document

section, I've observed a common occurrence in HTML pages where classes are referenced that don't seem to exist within the actual document. I wonder if these classes are being sourced from external locations or if they are simply concealed somewhe ...

One-page website with dynamic JavaScript features

Recently, I inherited a project for a client who already has a fully developed website. This website functions similar to a social media platform like Twitter, where users can create accounts, post 'tweets', and gain followers. Upon examining t ...

Is it a Mozilla Firefox glitch or something else?

After writing the code, I noticed a bug in Firefox and a small bug in Chrome. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...

Is your CSS file functioning properly in Chrome but not in Internet Explorer?

I recently developed a custom SAP Portal Component that includes a JSP file with Javascript. This component is placed on a SAP Portal page alongside another iView, which contains multiple headers and text within an iframe. My objective is to dynamically ge ...

How to efficiently update a child component in React using UseState and establish a connection back to the parent component

I am currently working on developing a prototype for a master/detail scenario in React and Material-UI. The task involves creating a basic list of objects with the ability to edit and save an item using a dialog. While I have successfully updated the visit ...

Navigating the way: Directing all TypeScript transpiled files to the build folder

I am currently working on a project using Angular2/Typescript, and I have the tsconfig.js file below: { "compilerOptions": { "module": "commonjs", "moduleResolution": "node", "target": "es5", "sourceMap": true, ...

Disable the javascript link on small devices

I currently have a javascript link (Trustwave) on my desktop website theme that I need to deactivate when viewed on mobile devices: Located in footer.tpl: <div style="position:absolute; margin-left:100px; margin-top:50px"> <script type="text/j ...