How can I move one of the multiple input fields to the top right side?

I am facing an issue and need some assistance. I have created a page with multiple font controls, but in my prototype design, there is a field on the right side where the inputs are positioned at the top and on the right. How can I achieve this?

I have created a snippet to test it out:

.StyleForm {
  margin-top: 230px;
  padding-left: 50px;
}

.StyleFormRest {
  padding-left: 50px;
}

.StyleFormRestRight {
  text-align: right;
  padding-right: 500px;
  margin-bottom: 5px;
  align-items: right;
}

#EmailDisplay,
#AddressDisplay,
#DescriptionDisplay {
  width: 875px;
}

.createMargin {
  margin-bottom: 15px;
}

.Email,
.ContactName,
.ContactNo,
.Address,
.Description {
  font-size: 18px;
}

#PriceModeDisplay {
  text-align: right;
}

.StyleFormRestRight .form-control {
  display: inline-block;
}
<div class="mb-3 StyleForm">
  <label for="Email" class="form-label"><b class="Email">Email</b></label>
  <input type="email" class="col-6 form-control" id="EmailDisplay" disabled readonly>
</div>
<form class="row g-3 StyleFormRest">
  <div class="col-4">
    <label for="Contact Name" class="visually-hidden"><b class="ContactName">Contact Name</b></label>
    <input type="text" class="form-control" id="ContactNameDisplay" disabled readonly>
  </div>
  <div class="col-2 createMargin">
    <label for="Contact No" class="visually-hidden"><b class="ContactNo">Contact No.</b></label>
    <input type="text" class="form-control" id="ContactNoDisplay" disabled readonly>
  </div>
</form>
<div class="mb-3 StyleFormRest">
  <label for="Address" class="form-label"><b class="Address">Address</b></label>
  <input type="text" class="col-6 form-control" id="AddressDisplay" disabled readonly>
</div>
<div class="mb-3 StyleFormRest">
  <label for="Description" class="form-label"><b class="Description">Description</b></label>
  <textarea class="form-control" id="DescriptionDisplay" rows="3" disabled readonly></textarea>
</div>

<div class="mb-3 StyleFormRestRight">
  <label for="PriceMode" class="form-label"><b class="PriceMode">Price Mode</b></label>
  <input type="text" class="col-2 form-control pull-right" id="PriceModeDisplay" disabled readonly>
</div>

My snippet is showing something different from how my current HTML page looks like: https://i.sstatic.net/3bYn2.png

As you can see, the price mode is positioned on the right side. Is there a way to move it to the top of the page as shown in the prototype design?

Prototype Design: https://i.sstatic.net/wFvFe.png

Answer №1

It seems like you're looking to create a two-column layout. The best way to achieve this is by using div elements with the display flex property. Here's how you can structure your HTML:

<div class="container">
  <div>...content for the left column...</div>
  <div>...content for the right column...</div>
</div>

.container {
  display: flex; /* Apply flexbox layout */
}

.StyleForm {
  margin-top: 230px;
  padding-left: 50px;
}

.StyleFormRest {
  padding-left: 50px;
}

.StyleFormRestRight {
  text-align: right;
  padding-right: 500px;
  margin-bottom: 5px;
  align-items: right;
}

#EmailDisplay,
#AddressDisplay,
#DescriptionDisplay {
  width: 875px;
}

.createMargin {
  margin-bottom: 15px;
}

.Email,
.ContactName,
.ContactNo,
.Address,
.Description {
  font-size: 18px;
}

#PriceModeDisplay {
  text-align: right;
}

.StyleFormRestRight .form-control {
  display: inline-block;
}
<div class="container"> <!-- Main container -->
  <div> <!-- Content for the right column -->
    <div class="mb-3 StyleForm">
      <label for="Email" class="form-label"><b class="Email">Email</b></label>
      <input type="email" class="col-6 form-control" id="EmailDisplay" disabled readonly>
    </div>
    <form class="row g-3 StyleFormRest">
      <div class="col-4">
        <label for="Contact Name" class="visually-hidden"><b class="ContactName">Contact Name</b></label>
        <input type="text" class="form-control" id="ContactNameDisplay" disabled readonly>
      </div>
      <div class="col-2 createMargin">
        <label for="Contact No" class="visually-hidden"><b class="ContactNo">Contact No.</b></label>
        <input type="text" class="form-control" id="ContactNoDisplay" disabled readonly>
      </div>
    </form>
    <div class="mb-3 StyleFormRest">
      <label for="Address" class="form-label"><b class="Address">Address</b></label>
      <input type="text" class="col-6 form-control" id="AddressDisplay" disabled readonly>
    </div>
    <div class="mb-3 StyleFormRest">
      <label for="Description" class="form-label"><b class="Description">Description</b></label>
      <textarea class="form-control" id="DescriptionDisplay" rows="3" disabled readonly></textarea>
    </div>
  </div>
  <div> <!-- Content for the left column -->
    <div class="mb-3 StyleFormRestRight">
      <label for="PriceMode" class="form-label"><b class="PriceMode">Price Mode</b></label>
      <input type="text" class="col-2 form-control pull-right" id="PriceModeDisplay" disabled readonly>
    </div>
  </div>
</div>

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

How can we generate 3 different arrays, each containing an equal number of items except for the last array, using VueJS?

Incorporating Bootstrap5 and VueJS 2, I am working on designing a layout of cards in a "pinterest-style" arrangement, as depicted in the following screenshot: https://i.sstatic.net/AvdWR.png To achieve the layout showcased above, the HTML markup required ...

Error in content policy for CSS in Stripe Checkout

I am currently attempting to integrate Stripe Checkout into my Ionic App. I have created a Directive that injects the form into my content view, however, upon execution, the CSS fails due to a content policy violation: checkout.js:2Refused to load the s ...

What is the mechanism behind image pasting in Firefox's imgur integration?

Start by launching an image editing software and make a copy of any desired image. Avoid copying directly from a web browser as I will explain the reason later on. Navigate to "http://imgur.com" using Firefox. To paste the copied image, simply press Ctrl+V ...

Unable to determine the reason why the JavaScript plugin is not functioning as expected

I have been attempting to set up a JS modal window and have essentially copied the code for the plugin exactly as instructed, but it is not functioning properly. Here is my code... <!doctype html> <html> <head> <meta charset="utf- ...

Save the output of my Java function into a JavaScript variable

I have created a web application using JSP, CSS and HTML. The page contains six buttons, each of which calls a JavaScript method. For instance, the first button triggers the par() method. <html> <head> <title>Welcome d To Student Unive ...

What is the best way to choose a specific section of a string using JQuery?

When utilizing the .html() function to retrieve html code, I encounter a need to extract a specific segment of the string. var newImgAdr = $(this).html(); The variable newImgAdr currently consists of: <img class="thumbnail-holder image-responsive cen ...

Managing state changes with a slider in ReactJS

I am currently working with the Foundation slider found at this link: click for doc. To access the slider's current value, they recommend using a hidden input like this: <div class="slider" data-slider data-initial-start="50" data-end="200"> & ...

Incorporating a slider into an HTML website

I'm currently working on designing a web page and I want to include a sliding input feature, although I am not entirely sure if it is referred to as a slider. ...

The CSS and JavaScript in pure form are not functioning properly upon deployment in Django

In my Django project, I am utilizing pure CSS and Bootstrap. Everything appears as expected when I test it on my local machine. However, once deployed, the appearance changes. The font looks different from how it did before deployment: After deploying to ...

Which names can be used for HTML form tags in jQuery?

Recently, I encountered an issue related to jQuery form serialization which stemmed from naming a form tag "elements". The problem arose when using jQuery $(’form’).serialize(). Here is an example of the problematic code: <form> <input name=" ...

Initiate a page break at the beginning of the table in case there are not enough lines on the first page

Does anyone know how to ensure that a table starts on a new page when printing, rather than continuing at the bottom of the previous page? I have tables with repeating headers and many rows, and sometimes a new table will start at the very end of a page. ...

In search of a CSS selector that can target elements based on specific text contained within them

Query: <div class="btn btn-second-in-pair-not-desired btn-tall">Clear search</div> <div class="btn btn-second-in-pair-not-desired btn-tall">Raw Search</div> <div class="btn btn-second-in-pair-not-desired btn-tall">Basic Searc ...

Ways to customize the appearance of Angular material elements one by one?

I have a component that contains two Angular Material form components: <!-- First input --> <mat-form-field> <mat-label>Password</mat-label> <input matInput type="text"> </mat-form-field> <br&g ...

Simple Way to Modify Color of Active Page Link - HTML, CSS, and JavaScript

I found a helpful example on how to change link colors for the current page here. Here is the script I added: <script> // current page highlight $(document).ready(function() { $("[href]").each(function() { if (this.href == window.l ...

Angular component causing style disruptions

As a newcomer to Angular, I am currently in the process of converting my previous project from .net to angular. However, I have encountered an issue that is specifically related to Angular, so please forgive me if it seems trivial. I am facing difficulti ...

What effect does jQuery animation have on content compression?

Looking for guidance as I dive into jQuery and navigate the complexities... HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <link rel="stylesheet" type="text/css" hre ...

occupying half of the screen

Having trouble displaying two videos in an ionic grid. My goal is to have both videos take up the entire screen, with each occupying 50% height and 100% width. However, when I try to achieve this, the ion-row only takes up 50% of the screen and the video i ...

Utilizing CSS and javascript to display position indicators on a map

I need help creating a basic webpage with the following functionality: The page will contain a map as a background image in a div, with clickable images placed on top (each within its own div). When these images are clicked, markers should appear or disap ...

PHP variable inaccessible

When using JQuery Ajax to call sessions variables from a PHP steamauth file, I encountered an issue. Even though the code works fine when "$data['test'] = "ok";" is used instead of "$data['test'] = $_SESSION['steamid'];", ther ...

Is it possible to adjust the font size in Bootstrap 4.6.2 to fit smaller fonts and bring back color to the tabs that were removed in the update?

While attempting to update Bootstrap from version 4.6.0 to 4.6.2 in a few codebases, I encountered some issues that prevented me from completing the upgrade successfully. The <small> tag and .small CSS class are now displaying larger than before. Ta ...