Place a div image on top of a form div

Currently, I have a simple form set up with the following HTML code:

<div class="card mb-5 card-central-responsive" style="min-height: 579px;">
  <div class="card-body">
    <form #apkCreationForm="ngForm" class="mt-2" novalidate  (ngSubmit)="onSubmitApk()">
      <div role="alert" class="mb-&  ng-star-inserted" style="padding-bottom: .10rem" ng-reflect-ng-class="">
        <h4 class="alert-heading">{{ 'apk.product-description' | translate }}</h4>
      </div>
      <div class="row">
        <div class="col-6">
          <label class="form-group has-float-label">
            <input class="form-control" required ngModel #name="ngModel" name="name" [(ngModel)]="apkName"/>
            <span>{{ 'apk.name' | translate }}</span>
            <div *ngIf="!name.valid && apkCreationForm.submitted" class="invalid-tooltip">{{ 'apk.name-required' | translate }}!</div>
          </label>
        </div>
        <div class="col-6">
          <label class="form-group has-float-label">
            <ng-select
              [items]="isFree"
              bindLabel="id"
              name="isFree"
              bindValue="id"
              [(ngModel)]="isFreeSelected">
            </ng-select>
            <span>{{ 'apk.is-free' | translate }}</span>
            <div *ngIf="!isFreeSelected && apkCreationForm.submitted" class="invalid-tooltip">{{ 'apk.isfree-required' | translate }}</div>
          </label>
        </div>
      </div>

      </div>
    </form >
  </div>
</div>

My goal is to incorporate a new div image at the top of this form, similar to the design shown in https://i.sstatic.net/CxsnJ.png.

I've attempted various solutions without any luck. Can someone guide me on how to achieve this? I am using ng-bootstrap in my application. Thank you in advance.

Answer №1

Utilizing Position absolute allows you to precisely align any element. I aim to simplify the process and demonstrate it in a straightforward manner.

body {
  background-color: #121723;
}

.container {
  margin-top: 200px;
}

.form-container {
  background-color: #252A39;
  color: #f1f1f1;
  height: 30rem;
  position: relative;
  padding-top: 40px;
}

.image-container {
  position: absolute;
  top: -30%;
  left: 5%;
  width: 15rem;
  height: 15rem;
  background-color: #2E3446;
  padding: 15px;
  border-radius: 3px;
}

.bordered-div {
  width: 100%;
  height: 100%;
  border: 3px dashed #121723;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

<div class="container">
  <div class="form-container">
    <!-- image-container -->
    <div class="image-container">
      <div class="bordered-div">
      </div>
    </div>
    <!-- image-container end -->
    <div class="row no-gutters form-tab">
      <div class="col-md-2 offset-md-3">
        <h6 class="text-capitalize text-right">product details</h6>
      </div>
      <div class="col-md-2">
        <h6 class="text-capitalize text-right">graphic assets</h6>
      </div>
      <div class="col-md-2">
        <h6 class="text-capitalize text-right">categorization</h6>
      </div>
    </div>
    <div class="form-input">
      <!-- Inputs  -->
    </div>

  </div>
</div>

Answer №2

To style your elements, consider using divs in CSS.

position: relative;
left: 50px;
top: 50px;

However, when dealing with various pixel measurements, it's important to embrace CSS flexibility.

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

Load the page's content gradually, without needing to wait for all the content to be fully loaded

I am facing an issue with a webpage that displays 10 different items, each of which has a slow loading time. Currently, the entire page waits for all 10 items to fully load before displaying anything. I am interested in finding out if it is feasible to sh ...

Which property within the <mat-option> element is used for toggling checkboxes on and off?

I'm experimenting with dynamically checking/unchecking a checkbox in mat-option. What attribute can I use for this? I've successfully done the same thing with mat-checkbox using [(ngModel)]. Here's the snippet of my code: app.component.html ...

What steps can I take to prevent BeautifulSoup from interpreting commas as tab characters?

My recent project involved creating a web scraping code to extract information from a local news website. However, I have encountered two issues with the current code. One problem is that when the code retrieves paragraph data and saves it to a CSV file ...

Customize Angular Material styles uniquely across various components

Within my application, I am utilizing two components that contain tab groups. The first component serves as the main page, where I have adjusted the CSS to enlarge the labels by using ViewEncapsulation.None. The second component is a dialog, and I aim to m ...

Error in External JavaScript File and Uncaught Reference Error

Wanting to utilize a separate Javascript file with my HTML code, I encountered an issue. Here is the code for the HTML document: <!DOCTYPE html> <html> <a href="javascript:showAlert()">Show Alert!</a> <script type="text/jav ...

adaptive menu bar with collapsible submenus

I would like to create a right side inline navigation bar with dropdown functionality. When the screen size is small, I want to hide all the menus and display a button. Clicking on the button should reveal a vertical navigation bar. I am facing an issue i ...

Unable to use document.write when extracting code from the internet

I am currently developing a game using emulatorjs and ruffle. The goal is to have it all contained in a single downloadable file that can be run locally. I attempted to create another file for auto-updating purposes, but encountered issues with some of the ...

Adjusting the size of a division element to match the dimensions

Currently, I am still in the process of finalizing the remainder of the page, but I have encountered a minor issue. The problem lies in my image div not matching the height of the container. Although the image itself is the correct size, the image div appe ...

Trouble getting CSS and JavaScript to function properly with HTTPS?

It seems that the css and js files are functioning properly on , but not on . As a novice in web design and javascript, I am struggling to find a solution to this issue. Trying to link the CSS file with "//isdhh.org/css/style.css" has not resolved the pr ...

Certain line borders are more robust compared to the rest

I have been working on a calendar application where I have designed boxes to display dates. However, I have encountered an issue where some of the line borders appear darker or thicker than others. Below is a snippet of my CSS and HTML code: <style> ...

Is there a more effective method for concealing arrows while scrolling?

I'm attempting to conceal the arrow that appears above the selected header, as depicted below. https://i.stack.imgur.com/wyxdF.png While scrolling, I aim to hide the arrow that appears on the header Company, especially when the first column is sticky ...

Guide on finding and replicating a particular string in HTML connected websites

Allow me to outline the issue at hand. By visiting the provided link, you will encounter a directory of html links containing stories by Aesop, each with its own moral. My goal is to extract and save only the strings that include "Moral of Aesop's Fab ...

Image expansion

I have a container element div that holds various content of unknown length. How can I add a background image that extends the entire length of the container since background-images do not stretch? I attempted to use a separate div with an img tag inside. ...

Steps for disabling automatic formatting in Visual Studio Code Version 1.35.1 with system setup

I am currently utilizing visual studio code for my Node JS application with mustache templating. In one of my HTML files, I have the following code: <script> {{{interface}}} </script> After the automatic formatting on save, it appears like t ...

What is the best way to adjust the size of table columns dynamically to accommodate content, align them to the left, and set a maximum

I came across many examples that are somewhat close to what I need, but I require more control over the table design. I want to prevent text wrapping, display ellipsis, and provide a tooltip when hovering over the content to view it completely. This proje ...

Javascript use of overlaying dynamically generated Canvases

Currently, I am developing a game to enhance my skills in HTML5 and Javascript. In the beginning, I had static canvases in the HTML body but found it difficult to manage passing them around to different objects. It is much easier for me now to allow each ...

The fusion of PHP and HTML coding

I have been attempting to integrate some PHP code into a combination of HTML and I am facing some challenges. Below is the code I am working with: <?php $result = mysqli_query($db,"SELECT * FROM classes"); while($record = mysqli_fetch_array($result)) ...

Tips for making modal body text reactive to different screen sizes

The text sent from JavaScript to the modal does not make the text_description element in the modal body responsive Modal Image https://i.sstatic.net/UJEG8.png HTML Code Snippet <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/boot ...

Modify th:hover in CSS to alter the background color

I currently have a table structured as follows: <table class="cedvel"> <caption> count: <%:Html.Encode(TempData["RowsCount"])%></caption> <thead> <tr&g ...

Learn how to use Bootstrap 4 to selectively filter through a list by their data attribute values

I am currently working with a PHP form that looks like this: <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>" role="search"> <label class="assistive-text" for="s"> &l ...