What is the best way to insert an image below my Bootstrap and Angular design?

I currently have the backgroundlogin.jpg image stored in the assets directory of my Angular project. I'm interested in learning how to position it below my layout, specifically in the white section indicated by the arrows in the figure provided below:

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

Here are the HTML and CSS codes for the project:

Login.component.html:

  <div class="jumbotron pt-5">
     <img class="center" src="../assets/images/full-banner1.jpg">
      <form class="form-signin jumbotron">
       <h2 class="form-signin-heading">LOGIN</h2>
       <label for="inputEmail" class="sr-only">Username</label>
       <input name="email" [(ngModel)] = "user.username" type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
       <label for="inputPassword" class="sr-only">Password</label>
       <input name="password" [(ngModel)] = "user.password" type="password" id="inputPassword" class="form-control" placeholder="Password" required>
        <div class="checkbox">
         <label>
         <input type="checkbox" value="remember-me">Remember me
         </label>
        </div>
       <button class="btn btn-lg btn-color btn-block" (click)="validateLogin();" type="button">Enter</button>
      </form>
     </div>
    <footer class="footer navbar-default" role="contentinfo">
     <div class="container">
      <p class="absolute">
       Created by Douglas
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
                <!-- Add font awesome icons -->
                <a href="#" class="fa fa-facebook"></a>
                <a href="#" class="fa fa-twitter"></a>
                <a href="#" class="fa fa-instagram "></a>
              </p>
    </div>
 </footer>

Login.component.css:

.center {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 50%;
}
.form-signin {
  max-width: 330px;
  padding: 15px;
  margin: 0 auto;
  background-color: black;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
  margin-bottom: 10px;
  color: lightgray;
}
.jumbotron{
  margin-top: 0 auto;
  background-color: black;
}
.form-signin .checkbox {
  font-weight: 400;
  color: lightgray;
}
.form-signin .form-control {
  position: relative;
  box-sizing: border-box;
  height: auto;
  padding: 10px;
  font-size: 16px;
}
.form-signin .form-control:focus {
  z-index: 2;
}
.form-signin input[type="email"] {
  margin-bottom: -1px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  background-color: white;
}
.form-signin input[type="password"] {
  margin-bottom: 10px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  background-color: white;
}
.btn-color {
 color: black;
 background-color: white;
}
.form-signin-heading{
  text-align-last: center;
  color: lightgray;
}

/* Style all font awesome icons */
.fa {
  padding: 20px;
  font-size: 30px;
  width: 50px;
  text-align: center;
  text-decoration: none;
}
/* Add a hover effect if you want */
.fa:hover {
  opacity: 0.7;
}
/* Facebook */
.fa-facebook {
  background: #3B5998;
  color: white;
}
/* Twitter */
.fa-twitter {
  background: #55ACEE;
  color: white;
}
.fa-instagram {
  background: rgb(216, 128, 182);
  color: white;
}
.footer{
  margin-top: 0;
  background:black;
}

The final outcome should resemble this:

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

Answer №1

Give this a shot.

custom-styles.scss

.image-background {
  background-image: url(./assets/images/your_picture.jpg);
  /* Full screen */
  height: 100%;

  /* Center and fit the image nicely */
  background-repeat: no-repeat;
  background-size: cover;
}

login.component.ts

ngOnInit(): void {
   const body = document.getElementsByTagName('body')[0];
   body.classList.add('image-background');
}

...

 ngOnDestroy(): void {
     const body = document.getElementsByTagName('body')[0];
     body.classList.remove('image-background');
 }
 

Make sure to include both OnInit & OnDestroy in your component like below, export class LoginComponent implements OnInit, OnDestroy { ... }

If you also want to remove black section, use this snippet.

.form-signin {
  max-width: 330px;
  padding: 15px;
  margin: 0 auto;
  background-color: transparent;
}

Answer №2

After confirming Janitha Rasanga's answer, I decided to implement the recommended adjustment:

background-image: url(./resources/img/background-login.jpg);

instead of

background-image: url(/assets/images/backgroundlogin.jpg);

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

Personalizing the snippets selection background on Stack Overflow

I'm currently working on designing a custom dark theme for Stack Overflow using Stylish. Everything was going smoothly until I encountered an issue while customizing a particular snippet. I'm having trouble changing the selection color to somethi ...

Troubleshooting: Resolving the "Cannot read property '...' of undefined" error in Angular service method within a template

After adding new functions to a service in my project, I encountered an error when trying to call a service function from my component template. The error message displayed was "Cannot read property 'isCompanyEligible' of undefined." I attempted ...

Looking for assistance with automated web testing using selenium

I am currently using Selenium to carry out testing on a web application, but I have encountered an issue. One of the nodes that needs to be clicked has a value that constantly changes upon startup. For example: click css=#f0012 > ins.jstree-icon At s ...

What is the best way to display one div on top of another when hovering over it?

Is there a way to show one div on top of another while hovering? The hovering action causes the second div to hide. You can see an example here - look for the DOWNLOAD button in the footer section, just above the footer widget. I'm looking for assis ...

Troubleshooting Problem with HTTP Requests in Angular 2 on Firefox Browser

I have encountered a peculiar issue with my Angular 2 application specifically on Firefox and all iOS browsers (Firefox, Safari). Whenever a user navigates to the /reports route in my application, I am making a REST API call using the ngOnInit method to f ...

What is the best way to enclose a handlebars expression within a span element while also making the span clickable?

In the button, the datePick string is a computed property that can be clicked on to trigger an event. However, clicking outside the datePick value inside the button does not trigger the event. Even after wrapping it inside a span and setting width: 100%, ...

Ensuring that the div remains confined within the Container

The code snippet provided below demonstrates that the lowest level of items is located outside the container. I understand that this is due to the position:absolute; transform:translate(-33%). However, this has been the only method I have found so far to ...

Trouble with Angular UI - Bootstrap Accordion and ng-include not functioning dynamically

I am facing an issue with the Accordion feature: I am trying to replicate what is shown in the demo. I have an Array of objects, each containing a title and a path to another HTML file which should be displayed when the accordion group is clicked. $scope ...

Create a dynamic function that adds a new property to every object in an array, generating unique values for

On my server, I have a paymentList JSON that includes date and time. Utilizing moment.js, I am attempting to create a new property called paymentTime to store the time data, but it seems to not update as expected. this.paymentList.forEach(element => ...

Managing touch devices and animations when hovering

Is there a way to remove or prevent all hover effects on a touch device? I've tried various scripts, but none seem to work for me. How can I test it with dev tools? I attempted this script but received an error: Cannot read property 'addEventList ...

Unnecessary Extra Spacing in Every <li> Tag

After searching thoroughly, the problem still remains elusive. Space seems to be mysteriously added to each list item within this code block. My suspicion lies with the for loop as it consistently adds a fixed amount of space. https://i.sstatic.net/0giRG. ...

Circular containers with text and subtitles arranged in a vertical alignment

I am struggling to find a solution for what seems like a simple task. I want to create 5 circular divs, each containing a letter grade with the subject title below it. Here is what I have tried so far: HTML: <div class="subject">A</div> <d ...

Trouble Aligning a CSS3 Canvas Within a Div

I'm facing a dilemma with my HTML code: <div id=test> <canvas id="pic" width="300" height="250"></canvas> </div> Whenever I attempt to adjust the width and height using CSS (by removing the width ...

I'm having trouble making the colors change on my Icon font/sprite rollover

I am currently attempting to position some related icons above my main navigation menu. The goal is to change the text and icon colors when a user hovers over a specific area (the tag with large padding). Unfortunately, I am facing challenges in achieving ...

When all y values are zero, Highcharts.js will shift the line to the bottom of the chart

Is there a way to move the 0 line on the y axis to the bottom of the chart when all values are 0? I attempted the solution provided in this post without success. Highcharts: Ensure y-Axis 0 value is at chart bottom http://jsfiddle.net/tZayD/58/ $(functi ...

Dynamic resizing of elements/images using jQuery to maintain proportions

My goal is to create a design where images resize proportionally with their containing elements. The challenge I am facing is achieving the proportional resizing of each image container's height as its width changes upon window resize. Currently, the ...

What could be the reason my nb-search is not visible on my page?

I designed a homepage with a navbar where I wanted to include the nebular search feature because I was impressed by its design. However, even after following their instructions, I still couldn't get it to show up. <nb-layout> <nb-layout-head ...

Angular - Implementing validation for maximum character length in ngx-intl-tel-input

Utilizing the ngx-intl-tel-input package in my Angular-12 project multistep has been quite promising. Below is a snippet of the code: Component: import { SearchCountryField, CountryISO, PhoneNumberFormat } from 'ngx-intl-tel-input'; expor ...

Leveraging property values in Angular 2 to dynamically generate HTML elements as tag names

Is it feasible to use a property as an HTML tag name? For instance, something along the lines of: <{{property.name}}>Hello world</{{property.name}}> ...

Why isn't the image adjusting its size to fit the container it's placed in? Am I missing something?

My issue involves getting an image to resize and stay within its designated div. However, the image continues to spill over onto the div below when I adjust the browser size or view it on my laptop. I have not set any fixed dimensions for the image. I am ...