What is the Best Way to Create a Form Inside a Box?

Hello there! I am trying to create a form underneath the box labeled "New Referral," but I'm having trouble figuring it out. I would like to include sections for first name, last name, date of birth, phone number, email, and address under the box. Any assistance would be greatly appreciated. I have shared my code snippet below. My goal is to display an icon next to the "First Name" text and have a line right under it, with similar styling for the other input fields as well.

* {
  margin: 0;
  border: 0;
  box-sizing: border-box;
  background: #CDE7ED;
}

... (additional CSS code here)

<header class="header">
    <div class="container">
        <nav id="navbar">
            <h1 class="heading1">Patient Referral Form Hayes Valley Health San Francisco </h1>

        </nav>
    </div>
</header>
<br>
<h2 class="iki">Referral Patients</h2>
<h3 class="uc">You can add up to five patients at a time</h3>
<div class="box">
    <div class="box-header">
        <div class="b1">
            <div class="b11">
                1
            </div>
        </div>
        <div class="new">
            New Referral 
        </div>
    </div>
    <br> 
</div>

Answer №1

Check out the following solution.

*{
    margin: 0;
    border: 0;
    box-sizing: border-box;

    background: #CDE7ED;
}

.heading1{
    position: absolute;
    width: 449px;
    height: 80px;
    top: 56px;

    font-family: 'Montserrat';
    ...
<!DOCTYPE html>
<html lang="en">

<head>
...
                <input type="text" name="state" id="state" class="refField">
                
            </form>

        </div>

    </body>

</html>

Answer №2

If you want to customize Labels:

* {
  margin: 0;
  border: 0;
  box-sizing: border-box;
  background: #CDE7ED;
}

.heading1 {
  position: absolute;
  width: 449px;
  height: 80px;
  top: 56px;
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  font-size: 30px;
  line-height: 40px;
  /* or 133% */
  text-align: center;
  background: #FFFFFF;
  color: #0B2B5B;
}

#menu {
  position: relative;
  height: 196px;
  top: 0px;
  display: flex;
  justify-content: center;
  background: #FFFFFF;
}

.item1 {
  height: 32px;
  left: 539px;
  top: 230px;
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  font-size: 24px;
  line-height: 32px;
  text-align: center;
  color: #0B2B5B;
}

.item2 {
  height: 32px;
  left: 435px;
  top: 270px;
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  font-size: 20px;
  line-height: 32px;
  /* identical to box height, or 160% */
  text-align: center;
  color: #0B2B5B;
}

.container {
  position: absolute;
  width: 782px;
  height: 380px;
  left: 470px;
  top: 334px;
  background: #FFFFFF;
  box-shadow: 0px 2px 4px rgba(11, 43, 91, 0.1);
  border-radius: 4px;
}

.header-box {
  width: 782px;
  height: 64px;
  left: 249px;
  top: 334px;
  background: #FFFFFF;
  border-radius: 4px 4px 0px 0px;
  display: flex;
}

.button-container {
  width: 40px;
  height: 64px;
  left: 249px;
  top: 334px;
  background: #25A575;
  border-radius: 4px 0px 0px 0px;
}

.button-text {
  width: 10px;
  height: 32px;
  left: 264px;
  top: 350px;
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  font-size: 26px;
  line-height: 32px;
  display: flex;
  align-items: center;
  text-align: center;
  font-feature-settings: 'pnum' on, 'lnum' on;
  color: #FFFFFF;
  background: #25A575;
}

.new-input {
  position: sticky;
  width: 132px;
  height: 24px;
  left: 305px;
  top: 354px;
  padding-left: 10px;
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 500;
  font-size: 20px;
  line-height: 24px;
  /* identical to box height, or 120% */
  display: flex;
  align-items: center;
  font-feature-settings: 'pnum' on, 'lnum' on;
  color: #3A719B;
  background-color: white;
}

.content-body {
  width: 295px;
  height: 16px;
  left: 24px;
  top: 0px;
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 400;
  font-size: 16px;
  line-height: 16px;
  /* identical to box height, or 100% */
  display: flex;
  align-items: center;
  color: #3A719B;
}

.line-divider {
  position: absolute;
  left: 0%;
  right: 0%;
  top: 100%;
  bottom: 0%;
  border: 1px solid #3A719B;
}
#form{
  display:flex;
  flex-direction:column;
}
<header class="header">
    <div class="container">
        <nav id="menu">
            <h1 class="heading1">Sample Form for Customization</h1>

        </nav>
    </div>
</header>
<br>
<h2 class="item1">Customize Items</h2>
<h3 class="item2">You have the freedom to alter up to five items</h3>
<div class="container">
    <div class="header-box">
        <div class="button-container">
            <div class="button-text">
                1
            </div>
        </div>
        <div class="new-input">
            Alter Item 
        </div>
      <form action="#" id="form">
        <label for="item1">Item</label>
        <input type="text" id="item1">
        
        
        <label for="name2">Name</label>
        <input type="text" id="name2">
        
        
        <label for="name3">Name</label>
        <input type="text" id="name3">
        
        
        <label for="name">Name</label>
        <input type="text" id="name">
        
        
        <label for="name4">Name</label>
        <input type="text" id="name4">
        
        
        <label for="name5">Name</label>
        <input type="text" id="name5">
        <button type="submit">Send</button>
      </form>
    </div>
    <br> 
</div>

Check out this link for additional details:

https://www.w3schools.com/html/html_forms.asp

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

When dynamically loaded HTML is involved, Javascript ajax calls often fail to execute properly

Currently, I am in the process of creating a JavaScript script that can facilitate clicking through <a href> links by only replacing the inner HTML instead of reloading the entire page. The interesting thing is, it seems to be functioning properly, e ...

CLS notifies about an Unrecognized CSS Element in Page Insights' Core Web Performance

My experience with Google PageSpeed Insights has been quite frustrating due to the numerous alerts I'm receiving about Unsupported CSS Properties. The importance of avoiding non-composited animations: Animations that are not composited can appear gli ...

When the web browser page is zoomed out (Ctrl -), elements do not appear to float

Can you test resizing the window to the minimum (CTRL-)? Here's the link: http://jsfiddle.net/Zty9k/13/ This is the HTML code: <ul> <li><img src="http://i.imgur.com/PBuDAFH.gif"></li> <li><img src="http://i.i ...

Steps for inserting a button within a table

Currently, I have implemented a function that dynamically adds the appropriate number of cells to the bottom of my table when a button is clicked. This is the JavaScript code for adding a row: <a href="javascript:myFunction();" title="addRow" class= ...

Having difficulty achieving the hover transition effect

I've been working on a navbar design and I'm having trouble getting the hover effect to work on the links. Specifically, I am trying to add a transform property to the after element of the links but it doesn't seem to be taking effect. #navb ...

After clicking on a specific href element with a designated class, trigger the display of a custom dialog styled using CSS

I recently added a unique class to certain links on my website. When these specific links are clicked, I want them to trigger a customized dialog box. My goal is to modify the CSS of this special dialog box. Only links with this particular class should ...

The querySelector function is now encountering errors due to a change in the data

Currently, I am utilizing a query selector to retrieve an input when a user selects different buttons. Initially, the buttons had options such as: 8x10 inch 12x16 inch 20x24 inch However, I made changes to the options format like so: 8" x 10" ...

Sass: Overcoming the challenge of the IE limitation on 4095 selectors per stylesheet

Hey there! Are you working on a Rails project with Sass & Compass? If you're using the Rails Asset Pipeline, check out this question. We're in the process of developing a large application with multiple use cases and various individually styled ...

Sticky Angular Headers

I am struggling to create a table on my angular page that has fixed headers and footers. <table class="table table-bordered table-striped table-hover" fixed-header> <thead> <tr> <th>Name</th> <t ...

Is there a way to enlarge images when hovered using canvas?

I came across a fascinating example at the following link: , where the images expand when hovered over. I am aware that this can be achieved using jquery, but I have concerns about its speed and reliability. I would like to experiment with d3.js, although ...

Embed HTML code to a website using a PHP script on a separate webpage

As a newcomer to PHP, I may have a silly question. Let's say I have a form: <form id="createNewGallery" name="newgallery" method="GET" action="code.php"><p><strong>please choose the number of pictures you want to upload: </str ...

Redirecting files from the file system to the emulator is not functioning properly

I am new to Phonegap and need help resolving this issue. In my application, I need to redirect to the List.html file when a button is clicked. Here is the code I have written: button1 function test() { window.location="/home/swift-03/phonegapexa ...

Create dynamic modals in ReactJS that appear when a row is clicked

Engaged in a project for an undisclosed entity where patient data is retrieved from their API and displayed as modal on the page. Clicking on a modal reveals more threat information in another modal. The objective is for these modals to render based on a c ...

Creating a scheduled redirect button using JavaScript and another button to cancel it

I'm facing an issue with my code. When the first button is clicked, it redirects the user to a different URL after 10 seconds. However, I'm struggling to make the second button cancel the redirect if pressed before the 10 seconds are up. Despite ...

unable to locate the nearest available table

This is my HTML code: <div id="dvUser"> <table id="tblUser" > <tbody> <tr> <td> <input class="sfCheckBox" type="checkbox" title="view" checked="checked"> </td> </tr> <tr> <td> <input class="sf ...

What strategies can be implemented by web publishers to block Amazon Affiliate DEEP-LINKS from redirecting to the Amazon App?

Currently, I am utilizing the Amazon-India affiliate program as a way to generate income from my website. The issue arises when a visitor accesses my site using their mobile browser (specifically Google Chrome) and clicks on one of my affiliate links - ins ...

Retrieving PHP information in an ionic 3 user interface

We are experiencing a problem with displaying data in Ionic 3, as the data is being sourced from PHP REST. Here is my Angular code for retrieving the data: this.auth.displayinformation(this.customer_info.cid).subscribe(takecusinfo => { if(takecusi ...

Customizing CSS by replacing link file styles with code in the HEAD section

UPDATE: After further examination, it appears that the code is functioning correctly. My apologies for any confusion. I am attempting to override certain CSS rules on specific pages. Below is an example of my approach. Can anyone confirm if this is a vali ...

Is there a way to align the input fields vertically?

Here is the link to my code on jsFiddle input { vertical-align: top; /* Not working */ } I am struggling to align the submit button under the input fields. Can someone provide assistance with this issue? ...

Adjusting Font Size for Buttons on Mobile Devices in HTML

I am currently working on a website that I want to ensure is mobile-friendly. When testing it on my phone and in Chrome's device mode, I noticed that the majority of the text on the screen was displayed at an easily readable size without needing to zo ...