Tony Webb
New Coder
Hi,
I've spen tsome time trying to work out how to set up an address form so that the elements (fields) display in rows of 2.
I'm not having much luck.
I've tried display-grid , display: flex, display: inline and a few others without success.
I'm almost there with using display flex but the titles show by the side of the field and sometimes it looks confusing ie three titles and only two fields on one row and the next row starting with a grid.
An example of the HTML code that I have used
How can I sort this out.
I've spen tsome time trying to work out how to set up an address form so that the elements (fields) display in rows of 2.
I'm not having much luck.
I've tried display-grid , display: flex, display: inline and a few others without success.
I'm almost there with using display flex but the titles show by the side of the field and sometimes it looks confusing ie three titles and only two fields on one row and the next row starting with a grid.
An example of the HTML code that I have used
How can I sort this out.
HTML:
<div class="address-form">
<form action="action_page.php">
<label for="fname">
<span>First Name</span>
</label>
<input type="text" id="fname" name="firstname" placeholder="Hew"/>
<br>
<label for="lname"><span>Last name</span></label>
<input type="text" id="lname" name="lastname" placeholder="Mcgrew"/>
<br>
<label for="ad-1">
<span>First line of address</span>
</label>
<input type="text" id="ad-1" name="ad-1" placeholder="25 Camberwick green">
<br>
<label for ad-2>
<span>Second Line of address</span>
</label>
<input type="text" id="ad-2" name="ad-1" placeholder="Fire Station">
<br>
<label for="county">
<span>County</span>
</label>
<input type="text" id="county" name="county" placeholder="Wessex">
<br>
<label form="p-code">
<span>Post Code</span>
</label>
<input type="text" id="p-code" name="post code" placeholder=" XY12 45CD">
<br>
<label form="fone">Phone number</label>
<input type="text" id="fone" name="phone" placeholder=" 012345678">
<br>
<label form="emale">
<span>Email Address</span>
</label>
<input type="email" id="emale" name="email" placeholder=" [email protected]">
<br>
</div>
CSS:
.address-form {margin-top: 20px;
margin-left: 20px;
color: blue;
display: flex;
flex-wrap: wrap;
align-items: center;
}
}
input[type=text], select, textarea {
margin-top: 100px;
width: 35%;
padding: 12px; /* Some padding */
border: 1px solid #ccc; /* Gray border */
border-radius: 4px; /* Rounded borders */
box-sizing: border-box; /* Make sure that padding and width stays in place */
margin-top: 6px; /* Add a top margin */
margin-bottom: 16px; /* Bottom margin */
resize: vertical /* Allow the user to vertically resize the textarea (not horizontally) */
}
/* Style the submit button with a specific background color etc */
input[type=submit] {
background-color: #04AA6D;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}