The background image is not properly aligned

I am struggling to set an image as the background for my first ASP.NET Core project. However, when I add the image, it also appears like a footer on the page instead of being positioned between the header and footer sections.

Here is a picture of the background

Below is my shared _Layout code:

@using CarRental.Common
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name = "viewport" content="width=device-width, initial-scale=1.0" />
        <title>@this.ViewData["Title"] - @GlobalConstants.SystemName</title>

        <link href = "~/lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" asp-append-version="true" />
        <link href = "~/css/site.min.css" rel="stylesheet" asp-append-version="true" />
    </head>
    <body>
        <header>
            <nav class="navbar navbar-expand-sm navbar-light bg-white border-bottom box-shadow mb-3">
                <div class="container">
                    <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">@GlobalConstants.SystemName</a>
                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                            aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
                        <partial name="_LoginPartial" />
                        <ul class="navbar-nav flex-grow-1">
                            <li class="nav-item">
                                <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link text-dark" asp-area="" asp-controller="Settings" asp-action="Index">Settings</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>
        </header>

        <div class="container">
            <partial name="_CookieConsentPartial" />
            <main role="main" class="pb-3">
                @this.RenderBody()
            </main>
        </div>

        <footer class="border-top footer text-muted">
            <div class="container">
                &copy; @DateTime.Now.Year - @GlobalConstants.SystemName - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
            </div>
        </footer>

        <script src="~/lib/jquery/dist/jquery.min.js" asp-append-version="true"></script>
        <script src="~/lib/jquery-validation/dist/jquery.validate.min.js" asp-append-version="true"></script>
        <script src="~/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js" asp-append-version="true"></script>
        <script src="~/lib/bootstrap/dist/js/bootstrap.min.js" asp-append-version="true"></script>
        <script src="~/js/site.min.js" asp-append-version="true"></script>
        @this.RenderSection("Scripts", required: false)
    </body>
</html>

Here is the home page code where I have added the background image:

@using CarRental.Common
@{
    this.ViewData["Title"] = "Home Page";
}
<style>
    body {
        background-image: url(/images/background-home.jpg);
        background-repeat: no-repeat;
        background-attachment: fixed;
    }
</style>

<div class="text-center">
    <h1 class="display-4" style="color:gold">Welcome to ElisCar! </h1>
</div>

I believe that I need to make adjustments in the home index.cshtml file to resolve this issue. Thank you.

Answer №1

To enhance the appearance of your footer, consider adding a background color similar to your header.

.footer {
    background-color: #ffffff;
}

Alternatively, you can apply the bg-white class to your <footer> element:

<footer class="border-top footer text-muted bg-white">

Answer №2

To ensure that the footer appears on top of the background image, increase the z-index value for the footer element.

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

Unable to locate web element using Selenium in C#

Here is the HTML code I am currently using: <div class="modal-footer"> <button class="btn btn-primary" type="button" value="Show Alert" ng-click="questions.getIrMessage()" data-dismiss="modal">Confirm</button> <button class ...

How can I create my own custom pagination and sorting features instead of relying on the default ui-bootstrap options?

Can anyone provide assistance with resolving conflicts I am experiencing while using ui-bootstrap? ...

Function in view.py of Django template not being called by Python method

I have been attempting to invoke a Python view method called res() in a Django template, but it doesn't seem to be working. This is the code for my View: class make_incrementor(object): def __init__(self, start): self.count=start ...

In React and Node Js, the setState function will return a value of NULL

My Node Js API utilizes a find function to retrieve data from the database, which works flawlessly and returns the results. However, when I pass this data into setState using React and Axios, it ends up returning null. Below is my API's find() functi ...

Creating a Circular Design with a Centered Line and Text Above and Below using Qualtrics (HTML/CSS/Java)

My knowledge of creating shapes and using these programming languages is limited. I am currently working on a survey in Qualtrics and I need to insert text into circular shapes. Creating one circle was straightforward, thanks to some helpful discussions ...

What is the process for rotating a 3-dimensional point?

I am currently working on developing a 3D renderer using JavaScript. Rendering cubes is going well, but I am looking to implement a rotation function for each cube. The goal is to rotate the x/y/z (pitch, roll, yaw) of every cube around its own axis. Th ...

What is the best way to detect when an option is selected in a Material UI autocomplete component?

Utilizing the autocomplete feature with filterOptions to propose adding a new value: <Autocomplete multiple name="participant-tags" options={people} getOptionLabel={(option) => option.name} renderInput={(param ...

How can I populate the second Select tag based on the selection made in the first Select tag using AngularJS

I am currently utilizing UI-Bootstrap in order to seamlessly integrate Angular and Bootstrap functionalities. My goal is to extract the value from a select tag contained within the "controllerCountries" controller, and then utilize that value as a paramete ...

Error occurred in next.js environment file when referencing process.env keys as strings in .env.local file

I have a .env.local file with various values stored in it. NEXT_PUBLIC_GA_ID = myvariablevalue I created a function to validate the presence of these values: export const getEnvValue = (name: string, required = true) => { const value = process.env[na ...

Concealing website links in the browser's address bar

Running my own website on a personal server with Ubuntu server, I noticed that my public IP address is displayed in the status bar when visitors browse my site or hover over links. Even after purchasing a domain name from godaddy, I couldn't find an o ...

Unable to load app.component.html on Plnkr

Plunker link: Click here to view the Plunker https://i.sstatic.net/QXZDv.png Resource Directory: https://i.sstatic.net/yS423.png app.ts File Content: import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/plat ...

How can you animate a MUI v4 Grid element using CSS transitions?

I was exploring the potential of using breakpoints in the MUI v4 component to control the visibility of items in my Grid System. How can I create a smooth CSS transition for b, transitioning from 0px to a defined breakpoint size of 3 for xl? Using % works ...

The express-fileupload throws an error saying "ENOENT: unable to locate the file or directory at 'public/images/name.ext'"

I am encountering an error ENOENT: no such file or directory, open 'public/images/name.ext from express-fileupload. I have searched for solutions to this issue, but none of the ones I found seem to work for me. Here are two examples: No such file or d ...

Display the percentage text behind a filling Bootstrap progress bar

I'm working on a bootstrap progress bar that displays a percentage along with the numerical value. Currently, the text fits next to the progress bar up until around 85%, after which it blocks the bar from growing further. You can see the issue in the ...

Is there a way to shift the page footer and bar down to the very bottom of the screen?

Is it possible to move the footer and footer bar to the very bottom of the page instead of just under the contents? I'm currently using the Sydney theme for WordPress and want the footer to sit across the bottom of the full-screen image. .footer-wid ...

Setting up ReactJS and TypeScript in a fresh MVC5 project from scratch

After extensively trying out various tutorials, I have yet to successfully run a basic MVC5 project using TypeScript and ReactJS. For reference, I have created these projects from scratch in Visual Studio 2015 with .NET 4.6.1, using the ASP.NET Web Applic ...

Utilizing the Angular @HostListener to retrieve the current viewport width upon loading - a simple guide

Currently, I am utilizing the Angular @HostListener to retrieve the current width of the viewport onResize() in the following manner: @HostListener('window:resize', ['$event']) onResize(event?) { window.innerWidth <= 400 ? ...

The placement of the image in the navigation bar is causing the links to be

Oddly enough, the links seem to be unclickable except when using Internet Explorer. I attempted adjusting the z-index and checked for conflicts multiple times, but unfortunately, it still won't cooperate. The issue seems to stem from the navigation ba ...

Ways to eliminate redundant older React components within a different library

Having trouble with material-ui in my React project as I encounter this error. Error: Invalid hook call. Ensure hooks are only called inside the body of a function component. Check for: Possible mismatch of React and renderer versions (i.e., React DOM) ...

Why is it that document.getElementById("xxxxx") does not seem to be functioning whatsoever?

I'm struggling to assign the value of a String Variable to a specific element in the DOM within a particular div. Let's use an example: game=TEN document.getElementById("game").innerHTML=game; The issue is that it does not write to: <div i ...