I am trying to design the following form where there will be 2 column. Each column can have any number of form field like left column can have only one form field and right column can have also one form field only or left column can have two form field and right column can have three form field and vice versa.
The way i am doing does not separates two columns. Here is what i have done
Here is what i tried using flex
.row {
display: flex;
}
.input-wrapper {
flex: 1;
padding-left: 15px;
}
<div class="row">
<div class="input-wrapper">
<label>Additional Space</label>
<select>
<option>hello</option>
</select>
</div>
<div class="input-wrapper">
<label>Size</label>
<input type="text" placeholder="length" />
</div>
<div class="input-wrapper">
<label></label>
<input type="text" placeholder="width" />
</div>
<div class="input-wrapper">
<label></label>
<select>
<option>hello</option>
</select>
</div>
</div>
<br/><br/><br/><br/><br/>
<div class="row">
<div class="input-wrapper">
<label>Additional Space</label>
<select>
<option>hello</option>
</select>
</div>
<div class="input-wrapper">
<label>Size</label>
<input type="text" placeholder="length" />
</div>
</div>
Here is the design
First, you need to set width: 100% to the input type you want to span. In your layout, the container already takes the full width.
You should also use display:flex on your input-wrapper and set
flex-direction: column;
justify-content: flex-end;
In order for the text to be shown first and the inputs on the second line.
.row {
display: flex;
}
.input-wrapper {
flex: 1;
padding-left: 15px;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
select{
width: 100%;
}
select, input{
border: 1px solid #e1e1e1;
padding: 6px;
border-radius: 3px;
}
label{
font-size: 14px;
color: #d1d1d1;
margin-bottom: 4px;
}
<div class="row">
<div class="input-wrapper">
<label>Additional Space</label>
<select>
<option>hello</option>
</select>
</div>
<div class="input-wrapper">
<label>Size</label>
<input type="text" placeholder="length" />
</div>
<div class="input-wrapper">
<label></label>
<input type="text" placeholder="width" />
</div>
<div class="input-wrapper">
<label></label>
<select>
<option>hello</option>
</select>
</div>
</div>
<br/><br/><br/><br/><br/>
<div class="row">
<div class="input-wrapper">
<label>Additional Space</label>
<select>
<option>hello</option>
</select>
</div>
<div class="input-wrapper">
<label>Size</label>
<input type="text" placeholder="length" />
</div>
</div>
Related
I have a problem with your form, how can I put the text and the elements at the same distance, e.g. show the label next to the fields, they are not on the same line, i.e. not centered on the line,
pls see pic on the Link
My Form
I have a problem with your form, how can I put the text and the elements at the same distance, e.g. show the label next to the fields, they are not on the same line, i.e. not centered on the line,
pls see pic on the Link
My Form
I have a problem with your form, how can I put the text and the elements at the same distance, e.g. show the label next to the fields, they are not on the same line, i.e. not centered on the line,
pls see pic on the Link
My Form
body{
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
background-color: #FFBB00;
}
.container{
width: 40%;
margin: 4% auto;
padding: 50px;
background-color: #fff;
border-radius: 15px;
box-shadow: #ccc 0 0 10px 0; /* للظل لحتى يطلع متناسب */
}
.title h1{
position: relative;
text-align: center;
font-size: 28px;
text-transform: uppercase;
}
.title h1::after{
content: "";
width: 30%;
height: 3px;
background-color: #FFBB00;
position: absolute;
top: 110%;
left: 35%;
}
.inputFeld{
padding: 10px;
margin: 10px;
border-radius:4px;
border: 1px solid #ccc;
}
.inputFeld:focus{
background-color: #FFBB00; ;
}
/* */
.parent-line{
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: center;
padding: 15px;
}
.parent-line .line-link{
display: flex;
flex: 1;
}
.parent-line .line-right{
flex: 1;
display: flex;
}
.parent-one-line{
padding: 15px;
}
.container .line label{
display: inline-block;
width: 150px;
text-align: left;
}
/* */
.btn{
padding: 19px 10px;
margin-bottom: 500px;
background-color: #000;
color: #fff;
border: none;
float: right;
cursor: pointer;
width: 100%;
}
.btn:hover{
background-color: #FFBB00;
color: #000;
}
.checken{
padding: 10px;
}
.select{
padding: 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<link rel="stylesheet" href="style.css">
<style>
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#300&display=swap');
</style>
<body>
<section class="container">
<dic class="title"><h1>ITEMS VERLINKEN </h1></dic>
<form action="">
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line"> <label class="" for=""> Link URL </label> <input class="inputFeld" type="text" name="" id="" > </div>
</div>
<div class="line-right">
<div class="line"> <label for=""> +articleNum+ </label> <input class="inputFeld" type="text" name="" id="" > </div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line"> <label for=""> Full PDF name </label> <input class="inputFeld" type="text" name="" id="" placeholder="Example: test.pdf ">
</div>
</div>
<div class="line-right">
<div class="line"> <label for=""> Full PDF Links </label>
<input class="checkbox" type="checkbox" name="" id="">
</div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line"> <label for=""> PDF Width in mm</label>
<input class="inputFeld" type="text" name="" id="" placeholder="Example: 212" size="4">
</div>
</div>
<div class="line-right">
<div class="line"> <label for=""> PDF Height in mm</label>
<input class="inputFeld" type="text" name="" id="" placeholder="Example: 290 " size="4">
</div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line">
<label for=""> Border around links</label>
<select class="select" name="" id="">
<option value="">No</option>
<option value="">Yes</option>
</select>
</div>
</div>
<div class="line-right">
<div class="line"> <label for=""> Border(RGB):</label>
<input class="inputFeld" type="text" name="" id="" placeholder="R" size="1">
<input class="inputFeld" type="text" name="" id="" placeholder="G" size="1" >
<input class="inputFeld" type="text" name="" id="" placeholder="B" size="1">
</div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line">
<label for=""> Border Width(mm)</label> <select class="select" name="" id="">
<option value="">0</option>
</select>
</div>
</div>
<div class="line-right">
<div class="line">
<label for="">Margin top (mm)</label> <select class="select" name="" id="">
<option value="">0</option>
</select>
</div>
</div>
</div>
<!-- -->
<div class="parent-one-line">
<div class="line"> <label for=""> Save settings: </label> <input class="inputFeld" type="text" name="" id="" placeholder="Example: Customer1 ">
<h5>Leave empty to prevent saving.</h5>
</div>
<input class="btn" type="button" value="Start">
</div>
</form>
</section>
</body>
</html>
Simply add align-items:center to
.parent-line .line-right{
flex: 1;
display: flex;
}
and increase/decrease input text height/font size to match the center.
I have 3 rows with 2 columns in each row on my HTML page with some labels and inputs.
I see a lot of space between the rows which I tried removing but didn't work. Is there a way to do it?
Here's the HTML Code :
<div >
<h1>
New Patient Record
</h1>
</div>
<div class="row" style="padding-bottom: 0px;">
<div class="column"></div>
<div class="column">
<label > <strong>Date</strong> </label>
<input type="date" name="date" id="date" class="form-control" [(ngModel)]="institutes.date">
</div>
</div>
<div class="row" style="padding-top:0px" >
<div class="container" style="padding-left: 7.5%" >
<form #institutesForm="ngForm" (ngSubmit)="instituteLogins(institutesForm)">
<div class="form-group">
<div class="row">
<div class="column">
<h2><strong> Symptoms</strong> </h2>
<input type="text" name="symtoms" id="symtoms" class="form-control"[(ngModel)]="institutes.symtoms">
<br>
<h2><strong>Diagnosis</strong></h2>
<label> <strong>Condition</strong> </label>
<input type="text" name="condition" id="condition" class="form-control"[(ngModel)]="institutes.condition">
<label><strong> Advice </strong></label>
<input type="text" name="advice" id="advice" class="form-control"[(ngModel)]="institutes.advice">
<br>
</div>
<div class="column">
<h2> <strong>Prescription</strong> </h2>
<br>
<label><strong> Medication </strong></label>
<input type="text" name="medication" id="medication" class="form-control"[(ngModel)]="institutes.medication">
<label><strong> Medicine Type </strong></label>
<input type="text" name="type" id="type" class="form-control"[(ngModel)]="institutes.type">
<label><strong>Course</strong></label>
<input type="text" id="course" name="course" class="form-control"[(ngModel)]="institutes.course">
<label><strong> How many per day? </strong></label>
<input type="text" name="cday" id="cday" class="form-control"[(ngModel)]="institutes.cday">
<br>
</div>
<div class="row">
<div class="column"></div>
<div class="column">
<button id="record" class="btn btn-primary" type="submit" >Add Record</button>
</div>
</div>
</div>
<br><br>
</div>
</form>
</div>
Here's what all I tried: I tried to adjust row spacing using margins, and padding but none of them worked. Is there any other alternative for this?
.modal-dialog.cascading-modal.modal-avatar .modal-header img {
width: 130px;
margin-left: auto;
margin-right: auto;
}
.modal-dialog.cascading-modal.modal-avatar .modal-header {
margin: -6rem 2rem -1rem 2rem;
}
.More{
color: blue;
margin-right: 100px;
}
.column{
margin : 100px;
}
.row{
margin:0;
padding:0;
align-items: baseline;
}
Changing:
.column{
margin: 100px;
}
To
.column{
margin-left : 100px;
margin-right: 100px;
}
Will remove the space between the rows. Is that the end result you're looking for?
Adjusting the margin-left helped me solve the issue.
Also using to add number of empty spaces vertically solved my UI design issues.
For the space between both rows, you can add the padding-bottom
style="margin-top:-50px"
Working on a project right now creating a bet page that I just can't get to format properly. I have tried encasing everything in its own div and putting those elements into a flex-container but when I do, everything seems to get thrown on-top of each other.
Im currently trying to get everything between the breaks into their own rows with 4 separate columns.
Any insight as to what I should look into using to get this formatted properly?
It is probably worth nothing that any JS is a little out of the scope of this project.
<!DOCTYPE html>
<html>
<style>
#chuckPage
{
margin:auto;
height: 50%;
width: 50%;
overflow: auto;
background-color: white;
padding: 25px;
border: 5px solid #ac5353;
text-align: center;
}
body
{
background-color: #59a659;
}
</style>
<head>
<meta charset="ISO-8859-1">
<title>Chuck-A-Luck</title>
</head>
<body>
<div id="chuckPage">
<h1>Choose your bets!</h1>
<h2>Current Purse: $1,000.00</h2>
<form action="Die" method="post">
<input type="checkbox" name="singleDie"> Single
<label>Die Select </label>
<select name="dieSelect">
<option value ="1">1</option>
<option value ='2'>2</option>
<option value ='3'>3</option>
<option value ='4'>4</option>
<option value ='5'>5</option>
<option value ='6'>6</option>
</select>
<input type="number" name="singleBetAmt" value="0" min="0" max="1000.0">
<p>1 Correct Die, 1:1, 2 Correct Dice, 2:1, 3 Correct Dice, 12:1</p>
<br><br>
<input type="checkbox" name="tripleDie"> Triple
<p>Any of the triples</p>
<input type="number" name="tripleBetAmt" value="0" min="0" max="1000.0">
<p>30:1</p>
<br><br>
<input type="checkbox" name="bigDie"> Big
<p>Sum of dice is 11 or higher (Doesn't work on triples)</p>
<input type="number" name="bigBetAmt" value="0" min="0" max="1000.0">
<p>1:1</p>
<br><br>
<input type="checkbox" name="smallDie"> Small
<p>Sum of dice is 10 or lower (Doesn't work on triples)</p>
<input type="number" name="smallBetAmt" value="0" min="0" max="1000.0">
<p>1:1</p>
<br><br>
<input type="checkbox" name="fieldDie"> Field
<p>Sum of dice is outside of or 8 and 12</p>
<input type="number" name="fieldBetAmt" value="0" min="0" max="1000.0">
<p>1:1</p>
<br><br>
<input type = "submit" name="sendData" value="Place Your Bet!">
</form>
</div>
</body>
</html>
Here is an example I was given to work towards.
Click me to see the example i was given
Tables are definitely a viable way to go—but let's consider flexbox. With a little tweaking in the HTML, we can create rows and columns and add responsiveness. Adding responsiveness with tables is possible, but not a pleasant developer experience.
In the following example, I set up the flex row columns to assume 25% of available row space. When the screen is smaller than 750px, there's no room for 4 columns of data and I change the column width to 50%.
Make sure to test in Full page mode.
#chuckPage {
margin: auto;
height: 50%;
overflow: auto;
background-color: white;
padding: 25px;
border: 5px solid #ac5353;
text-align: center;
}
body {
background-color: #59a659;
}
form[action="Die"] {
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
form[action="Die"] .row {
display: flex;
flex-wrap: wrap;
align-items: center;
border-bottom: 2px solid gray;
}
form[action="Die"] .col {
flex-basis: 25%;
text-align: left;
}
#media screen and (max-width: 750px) {
form[action="Die"] .col {
flex-basis: 50%;
}
}
<div id="chuckPage">
<h1>Choose your bets!</h1>
<h2>Current Purse: $1,000.00</h2>
<form action="Die" method="post">
<div class="row">
<div class="col">
<input type="checkbox" name="singleDie"> Single
<label>Die Select </label>
</div>
<div class="col">
<select name="dieSelect">
<option value="1">1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
</select>
</div>
<div class="col">
<input type="number" name="singleBetAmt" value="0" min="0" max="1000.0">
</div>
<div class="col">
<p>1 Correct Die, 1:1, 2 Correct Dice, 2:1, 3 Correct Dice, 12:1</p>
<br><br>
</div>
</div>
<div class="row">
<div class="col">
<input type="checkbox" name="tripleDie"> Triple
</div>
<div class="col">
<p>Any of the triples</p>
</div>
<div class="col">
<input type="number" name="tripleBetAmt" value="0" min="0" max="1000.0">
</div>
<div class="col">
<p>30:1</p>
<br><br>
</div>
</div>
<div class="row">
<div class="col">
<input type="checkbox" name="tripleDie"> Triple
</div>
<div class="col">
<p>Any of the triples</p>
</div>
<div class="col">
<input type="number" name="tripleBetAmt" value="0" min="0" max="1000.0">
</div>
<div class="col">
<p>30:1</p>
<br><br>
</div>
</div>
<div class="row">
<div class="col">
<input type="checkbox" name="tripleDie"> Triple
</div>
<div class="col">
<p>Any of the triples</p>
</div>
<div class="col">
<input type="number" name="tripleBetAmt" value="0" min="0" max="1000.0">
</div>
<div class="col">
<p>30:1</p>
<br><br>
</div>
</div>
<div class="row">
<div class="col">
<input type="checkbox" name="tripleDie"> Triple
</div>
<div class="col">
<p>Any of the triples</p>
</div>
<div class="col">
<input type="number" name="tripleBetAmt" value="0" min="0" max="1000.0">
</div>
<div class="col">
<p>30:1</p>
<br><br>
</div>
</div>
</form>
</div>
If you want the result page to look same as the sample image, you can explore Table tag and specify every item in rows and columns of the table respectively.
Hope this helps!!
I have created a form that is aligned horizontally with the labels on top.
I had some difficulty aligning the = button, and I used a trick with   to align it. I couldn't find any better solution for this, is there something better to do?
I want to apply a border around the form and align it in the center of the page.
I have tried several things, like placing it inside a table, or using another div but with no success.
This is my code until now (I have not included the script for the calculations):
<!DOCTYPE html>
<html>
<head>
<title> Calculator</title>
<style>
input, label{
display:block;
}
label{
text-align:center;
margin-bottom:4px;
}
</style>
</head>
<body>
<h1 style="text-align:center">Calculator</h1>
<form name="CL">
<div style="float:left;margin-right:20px;">
<label for="N1">X</label>
<input type="text" name="N1" id="N1">
</div>
<div style="float:left;margin-right:20px;">
<label for "O">Operator</label>
<select type="text" name="O" id="O" style="width:50px">
<option value="0"> +</option>
<option value="1">-</option>
<option value="2">*</option>
<option value="3">/</option>
</select>
</div>
<div style="float:left;margin-right:20px;">
<label for="N2">Y</label>
<input type="text" name="N2" id="N2">
</div>
<div style="float:left;">
<label>  </label>
<input type="button" value="=" onclick="calc()">
</div>
<div style="float:left;">
<label for="R">Result</label>
<input type="text" name="R" id="R">
</div>
</div>
</form>
</body>
</html>
You can create a wrapper DIV around it and make that a flex container, using the following settings to achieve the centering both horizontally and vertically:
html,
body {
height: 100%;
}
.wrapper {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
form {
padding: 10px;
border: 1px solid #ddd;
}
<!DOCTYPE html>
<html>
<head>
<title> Calculator</title>
<style>
input,
label {
display: block;
}
label {
text-align: center;
margin-bottom: 4px;
}
</style>
</head>
<body>
<div class="wrapper">
<h1 style="text-align:center">Calculator</h1>
<form name="CL">
<div style="float:left;margin-right:20px;">
<label for="N1">X</label>
<input type="text" name="N1" id="N1">
</div>
<div style="float:left;margin-right:20px;">
<label for "O">Operator</label>
<select type="text" name="O" id="O" style="width:50px">
<option value="0"> +</option>
<option value="1">-</option>
<option value="2">*</option>
<option value="3">/</option>
</select>
</div>
<div style="float:left;margin-right:20px;">
<label for="N2">Y</label>
<input type="text" name="N2" id="N2">
</div>
<div style="float:left;">
<label>  </label>
<input type="button" value="=" onclick="calc()">
</div>
<div style="float:left;">
<label for="R">Result</label>
<input type="text" name="R" id="R">
</div>
</form>
</div>
</body>
</html>
What you might do is give the form a width and use margin: 0 auto to align it in the middle and set overflow: auto;
For example:
input, label{
display:block;
}
label{
text-align:center;
margin-bottom:4px;
}
form {
width: 90%;
margin: 0 auto;
border: 1px solid #ccc;
overflow: auto;
padding: 5px;
}
form div {
float: left;
margin-right:20px;
}
<!DOCTYPE html>
<html>
<head>
<title> Calculator</title>
<style>
input,
label {
display: block;
}
label {
text-align: center;
margin-bottom: 4px;
}
form {
width: 90%;
margin: 0 auto;
border: 1px solid #ccc;
overflow: auto;
padding: 5px;
}
form div {
float: left;
margin-right: 20px;
}
</style>
</head>
<body>
<h1 style="text-align:center">Calculator</h1>
<form name="CL">
<div>
<label for="N1">X</label>
<input type="text" name="N1" id="N1">
</div>
<div>
<label for="O">Operator</label>
<select name="O" id="O" style="width:50px">
<option value="0"> +</option>
<option value="1">-</option>
<option value="2">*</option>
<option value="3">/</option>
</select>
</div>
<div>
<label for="N2">Y</label>
<input type="text" name="N2" id="N2">
</div>
<div>
<label>  </label>
<input type="button" value="=" onclick="calc()">
</div>
<div>
<label for="R">Result</label>
<input type="text" name="R" id="R">
</div>
</form>
</body>
</html>
I made every option into a container, so I have 8 containers, from left to right, from top to bottom.
But for some unknown reason, item_container 3 and 4 are not following the alignment!! I've spent hours on this but no good. So frustrating right now.
Here is my html code. item_container 5~8 are basically the same as 1,2, and they aligned perfectly, so I didn't include them.
.page_item {
display: inline-block;
margin-left: 28px;
margin-right: 8px;
margin-bottom: 1px;
}
.page_field {
display: inline-block;
margin-right: 68px;
margin-bottom: 1px;
}
.page_check_field {
display: inline-block;
margin-right: 8px;
margin-bottom: 1px;
}
.page_container {
display: block;
width: 876px;
height: 74px;
}
.page_container .item_container1, .page_container .item_container2, .page_container .item_container3, .page_container .item_container4, .page_container .item_container5, .page_container .item_container6, .page_container .item_container7, .page_container .item_container8 {
display: inline-block;
}
.item_container1, .item_container2, .item_container3 .item_container4, .item_container5, .item_container6, .item_container7, .item_container8 {
display: inline-block;
width: 436px;
}
<div class="page_container">
<div class="item_container1">
<h6 class="page_item">User ID</h6>
<div class="page_field form-group form-group-label">
<label class="page_entry floating-label" for="..."> Entry User ID </label>
<input class="form-control" id="..." type="text">
</div>
</div>
<div class="item_container2">
<h6 class="page_item">Country</h6>
<div class="page_field form-group form-group-label">
<select class="page_entry form-control" id="...">
<option value="..."> Select </option>
<option value="..."> Country 1 </option>
<option value="..."> Country 2 </option>
<option value="..."> Country 3 </option>
<option value="..."> Country 4 </option>
<option value="..."> Country 5 </option>
<option value="..."> Country that has very long name </option>
</select>
</div>
</div>
</div>
<div class="page_container">
<div class="item_container3">
<h6 class="page_item">Email</h6>
<div class="page_field form-group form-group-label">
<label class="floating-label" for="..."> Entry User Email </label>
<input class="form-control" id="..." type="text">
</div>
</div>
<div class="item_container4">
<h6 class="page_item">User Type</h6>
<div class="page_check_field">
<div class="checkbox checkbox-adv">
<label for="check1">
<input class="access-hide" id="check1" name="check1" type="checkbox">Cosplayer
<span class="checkbox-circle"></span>
<span class="checkbox-circle-check"></span>
<span class="checkbox-circle-icon icon">done</span>
</label>
</div>
</div>
<div class="page_check_field">
<div class="checkbox checkbox-adv">
<label for="check2">
<input class="access-hide" id="check2" name="check2" type="checkbox">Cameraman
<span class="checkbox-circle"></span>
<span class="checkbox-circle-check"></span>
<span class="checkbox-circle-icon icon">done</span>
</label>
</div>
</div>
<div class="page_check_field">
<div class="checkbox checkbox-adv">
<label for="check3">
<input class="access-hide" id="check3" name="check3" type="checkbox">Organizer
<span class="checkbox-circle"></span>
<span class="checkbox-circle-check"></span>
<span class="checkbox-circle-icon icon">done</span>
</label>
</div>
</div>
</div>
</div>
There's a missing comma in this line that's probably causing your trouble
.item_container2, .item_container3 .item_container4,
The reason for this issue is .page-container don't width enough.
.item_container4 too large over the .page-container width.
To fix this simply you only need change width of .page-container larger .
Can be set width :
.page-container {
width: 920px;
.........
}
It work correctly!
Hope it help
.item_container1, .item_container2, .item_container3, .item_container4, .item_container5, .item_container6, .item_container7, .item_container8 {
display: inline-block;
width: 436px;
}
, between item_container3 and item_container4 is missing and i thought you might be adjust your width for better look