I have a parent div with 3 child divs inside. I need that each child div take one third of the screen and that all elements (text, button and input) inside of each divs are responsive by always being to the center of the child divs.
I could make in sort that each child divs takes one third of the screen but the elements aren't responsive and are diving themselves in two columns inside the child divs, like seen in the picture below:
Here is the code used:
input,
select,
textarea {
width: 100%;
padding: 6px;
border: 1px solid #ccc;
border-radius: 5px;
}
label {
padding: 12px 12px 12px 0;
display: inline-block;
}
.Order_Create_Ship_Stock>div {
width: 30%;
margin: 5px;
padding: auto;
display: inline-table;
border: solid;
}
.Order_Create,
.Order_Ship,
.Order_Store {
border-radius: 5px;
background-color: #f2f2f2;
padding: 10px;
display: table-cell;
}
#SubmitCreateOrder,
#SubmitShipOrder,
#SubmitStoreOrder {
cursor: pointer;
display: flex;
flex-direction: column;
}
<div id="OrderCreateShipStock" class="Order_Create_Ship_Stock">
<div id="OrderCreate" class="Order_Create">
<form onsubmit="App.createOrder(); return false">
<label for="BarcodeInput">
<span>Barcode</span>
<input name="BarcodeInput"id="Barcode" class="Barcorde" type="text" placeholder="Order's Barcode...">
</label>
<label for="OwnerInput">
<span>Owner</span>
<input name="OwnerInput" id="Owner" class="Owner" type="text" placeholder="Owner of the product...">
</label>
<label for="ProductListInput">
<span>Product list</span>
<input name="ProductListInput" id="ProductList" class="Product_List" type="text" placeholder="Product list of the order....">
</label>
<label for="ExpirationDateInput">
<span>Expiration date</span>
<input name="ExpirationDateInput" id="ExpirationDate" class="Expiration_Date" type="date">
</label>
<label for="TemperatureMinimalInput">
<span>Temperature minimal</span>
<input name="TemperatureMinimalInput" id="TemperatureMinimal" class="Temperature_Minimal" type="number" placeholder="Minimal temperature of order's environment...">
</label>
<label for="TemperatureMaximalInput">
<span>Temperature maximal</span>
<input name="TemperatureMaximalInput" id="TemperatureMaximal" class="Temperature_Maximal" type="number" placeholder="Maximal temperature of order's environment...">
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select name="IOTDeviceInput" id="IOTDevice" class="IOT_Device">
<option value="">---Please select an IOT Device---</option>
</select>
</label>
<label for="FinalDestinationInput">
<span>Final destination</span>
<input name="FinalDestinationInput" id="FinalDestination" class="Final_Destination" type="text" placeholder="Order's final destination...">
</label>
<button id="SubmitCreateOrder" class="Submit_Create_Order" type="submit">Create Order</button>
</form>
</div>
<div id="OrderShip" class="Order_Ship">
<form onsubmit="App.ShipOrder(); return false">
<label for="OrderIDInput">
<span>OrderID</span>
<input name="OrderIDInput" id="OrderID" class="Order_ID" type="text" placeholder="Order's ID">
</label>
<label for="ActualLocationInput">
<span>Actual location</span>
<input name="ActualLocationInput" id="ActualLocation" class="Actual_Location_Input" type="text" placeholder="Order's actual location">
</label>
<label for="ActualTemperatureInput">
<span>Actual temperature</span>
<input name="ActualTemperatureInput" id="ActualTemperature" class="Actual_Temperature" type="text" placeholder="Order's actual environment temperature">
</label>
<label for="CurrentCounterpartyInput">
<span>Counterparty</span>
<input name="CurrentCounterpartyInput" id="CurrentCounterparty" class="Current_Counterparty" type="text" placeholder="Order's current counterparty">
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select name="IOTDeviceInput" id="IOTDevice" class="IOT_Device_Input">
</select>
</label>
<label for="AnticipatedDateInput">
<span>Anticipated date</span>
<input name="AnticipatedDateInput" id="AnticipatedDate" class="Anticipated_Date" type="date">
</label>
<label for="DestinationInput">
<span>Destination</span>
<input name="DestinationInput" id="Destination" class="Destination_" type="text" placeholder="Order's destination">
</label>
<button id="SubmitShipOrder" class="Submit_Ship_Order" type="submit">Ship Order</button>
</form>
</div>
<div id="OrderStore" class="Order_Store">
<form onsubmit="App.storeOrder(); return false">
<label for="OrderIDInput">
<span>OrderID</span>
<input name="OrderIDInput" id="OrderID" class="Order_ID" type="text" placeholder="Order's ID">
</label>
<label for="ActualLocationInput">
<span>Actual location</span>
<input name="ActualLocationInput" id="ActualLocation" class="Actual_Location_Input" type="text" placeholder="Order's actual location">
</label>
<label for="ActualTemperatureInput">
<span>Actual temperature</span>
<input name="ActualTemperatureInput" id="ActualTemperature" class="Actual_Temperature" type="text" placeholder="Order's actual environment temperature">
</label>
<label for="CurrentCounterpartyInput">
<span>Counterparty</span>
<input name="CurrentCounterpartyInput" id="CurrentCounterparty" class="Current_Counterparty" type="text" placeholder="Order's current counterparty">
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select name="IOTDeviceInput" id="IOTDevice" class="IOT_Device_Input">
<option value="">---Please select an IOT Device---</option>
</select>
</label>
<button id="SubmitStoreOrder" class="Submit_Store_Order" type="submit">Store Order</button>
</form>
</div>
</div>
While I was working I could somehow make in sort that the buttons remains in one column by using flexbox (flex-direction: column), but this method didn't work for the inputs and textarea...
So I would like to ask some help to make in sort that all elements inside these child divs remain in only one column please.
I thank in advance anybody who will take the time to help me.
For the buttons, adding margin: auto, centered any child will do the job and I add one more option to the first Button if you find useful to make it a full button.
Also for the container to be responsive, you can to set the parent the flex box. Then set all child with flex: 1 and use media queries to make it columns.
/* --- FOR THE CONTAINERS --- */
#OrderCreateShipStock {
display: flex;
}
.Order_Create_Ship_Stock>div {
margin: 5px;
border: solid;
flex: 1;
}
#media only screen and (max-width: 800px) {
#OrderCreateShipStock {
flex-wrap: wrap;
flex-direction: column;
}
}
/* --- BUTTON CENTERED --- */
#SubmitCreateOrder, #SubmitShipOrder, #SubmitStoreOrder {
display: flex;
margin: auto;
}
/* --- BUTTON FULL CENTERED TEXT --- */
#SubmitCreateOrder, #SubmitShipOrder, #SubmitStoreOrder {
width: 100%;
justify-content: center;
align-items: center;
}
input,
select,
textarea {
width: 100%;
padding: 6px;
border: 1px solid #ccc;
border-radius: 5px;
}
label {
padding: 12px 12px 12px 0;
display: inline-block;
}
#OrderCreateShipStock {
display: flex;
}
.Order_Create_Ship_Stock>div {
margin: 5px;
border: solid;
flex: 1;
}
.Order_Create,
.Order_Ship,
.Order_Store {
border-radius: 5px;
background-color: #f2f2f2;
padding: 10px;
display: table-cell;
}
#SubmitCreateOrder,
#SubmitShipOrder,
#SubmitStoreOrder {
display: flex;
margin: auto;
}
#SubmitCreateOrder {
width: 100%;
justify-content: center;
align-items: center;
}
#media only screen and (max-width: 500px) {
#OrderCreateShipStock {
flex-wrap: wrap;
flex-direction: column;
}
}
<div id="OrderCreateShipStock" class="Order_Create_Ship_Stock">
<div id="OrderCreate" class="Order_Create">
<form onsubmit="App.createOrder(); return false">
<label for="BarcodeInput">
<span>Barcode</span>
<input name="BarcodeInput"id="Barcode" class="Barcorde" type="text" placeholder="Order's Barcode...">
</label>
<label for="OwnerInput">
<span>Owner</span>
<input name="OwnerInput" id="Owner" class="Owner" type="text" placeholder="Owner of the product...">
</label>
<label for="ProductListInput">
<span>Product list</span>
<input name="ProductListInput" id="ProductList" class="Product_List" type="text" placeholder="Product list of the order....">
</label>
<label for="ExpirationDateInput">
<span>Expiration date</span>
<input name="ExpirationDateInput" id="ExpirationDate" class="Expiration_Date" type="date">
</label>
<label for="TemperatureMinimalInput">
<span>Temperature minimal</span>
<input name="TemperatureMinimalInput" id="TemperatureMinimal" class="Temperature_Minimal" type="number" placeholder="Minimal temperature of order's environment...">
</label>
<label for="TemperatureMaximalInput">
<span>Temperature maximal</span>
<input name="TemperatureMaximalInput" id="TemperatureMaximal" class="Temperature_Maximal" type="number" placeholder="Maximal temperature of order's environment...">
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select name="IOTDeviceInput" id="IOTDevice" class="IOT_Device">
<option value="">---Please select an IOT Device---</option>
</select>
</label>
<label for="FinalDestinationInput">
<span>Final destination</span>
<input name="FinalDestinationInput" id="FinalDestination" class="Final_Destination" type="text" placeholder="Order's final destination...">
</label>
<button id="SubmitCreateOrder" class="Submit_Create_Order" type="submit">Create Order</button>
</form>
</div>
<div id="OrderShip" class="Order_Ship">
<form onsubmit="App.ShipOrder(); return false">
<label for="OrderIDInput">
<span>OrderID</span>
<input name="OrderIDInput" id="OrderID" class="Order_ID" type="text" placeholder="Order's ID">
</label>
<label for="ActualLocationInput">
<span>Actual location</span>
<input name="ActualLocationInput" id="ActualLocation" class="Actual_Location_Input" type="text" placeholder="Order's actual location">
</label>
<label for="ActualTemperatureInput">
<span>Actual temperature</span>
<input name="ActualTemperatureInput" id="ActualTemperature" class="Actual_Temperature" type="text" placeholder="Order's actual environment temperature">
</label>
<label for="CurrentCounterpartyInput">
<span>Counterparty</span>
<input name="CurrentCounterpartyInput" id="CurrentCounterparty" class="Current_Counterparty" type="text" placeholder="Order's current counterparty">
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select name="IOTDeviceInput" id="IOTDevice" class="IOT_Device_Input">
</select>
</label>
<label for="AnticipatedDateInput">
<span>Anticipated date</span>
<input name="AnticipatedDateInput" id="AnticipatedDate" class="Anticipated_Date" type="date">
</label>
<label for="DestinationInput">
<span>Destination</span>
<input name="DestinationInput" id="Destination" class="Destination_" type="text" placeholder="Order's destination">
</label>
<button id="SubmitShipOrder" class="Submit_Ship_Order" type="submit">Ship Order</button>
</form>
</div>
<div id="OrderStore" class="Order_Store">
<form onsubmit="App.storeOrder(); return false">
<label for="OrderIDInput">
<span>OrderID</span>
<input name="OrderIDInput" id="OrderID" class="Order_ID" type="text" placeholder="Order's ID">
</label>
<label for="ActualLocationInput">
<span>Actual location</span>
<input name="ActualLocationInput" id="ActualLocation" class="Actual_Location_Input" type="text" placeholder="Order's actual location">
</label>
<label for="ActualTemperatureInput">
<span>Actual temperature</span>
<input name="ActualTemperatureInput" id="ActualTemperature" class="Actual_Temperature" type="text" placeholder="Order's actual environment temperature">
</label>
<label for="CurrentCounterpartyInput">
<span>Counterparty</span>
<input name="CurrentCounterpartyInput" id="CurrentCounterparty" class="Current_Counterparty" type="text" placeholder="Order's current counterparty">
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select name="IOTDeviceInput" id="IOTDevice" class="IOT_Device_Input">
<option value="">---Please select an IOT Device---</option>
</select>
</label>
<button id="SubmitStoreOrder" class="Submit_Store_Order" type="submit">Store Order</button>
</form>
</div>
</div>
Just found the error, I just needed to add to label and not input, select the following:
display: flex;
flex-direction: column;
Related
I need to do this only using flex but I am having some difficulty aligning my labels and input fields properly.This is what the end result is supposed to look like.
Any help would be appreciated!
<form>
<div class="details">
<label for="email">E-mail:</label>
<input type="email" id="email" name="email">
</div>
<div class="details">
<label for="tel">Telephone Number:</label>
<input type="tel" id="tel" name="tel">
</div>
<div class="details">
<label for="position">Position:</label>
<input type="text" id="position" name="position">
<input type="radio" name="availability" id="Part-Time" value="Part-Time">
<label for="radio">Part-Time</label>
<input type="radio" name="availability" id="Full-Time" value="Full-Time">
<label for="radio">Full-Time</label>
</div>
<div class="details">
<label for="date">Date:</label>
<input type="date" id="date" name="date">
<input type="checkbox" name="AM" id="AM" value="AM">
<label for="checkbox">AM</label>
<input type="checkbox" name="PM" id="PM" value="PM">
<label for="radio">PM</label>
</div>
<div class="details">
<label for="yearsofexperience">Years of Experience:</label>
<input type="text" id="yearsofexperience" name="yearsofexperience">
</div>
<div class="details">
</div>
<div class="details">
<label for="experience">Experience:</label>
<textarea name="experience" id="experience" rows="1" cols="20">Worked 5 years at Bayshore Veterinarian Services</textarea>
</div>
<div class="details">
<input type="submit" value="Apply Now">
</div>
</form>
I have tried all sorts of things but i cannot get them to line up. I have tried having two columns where column 1 contains the labels, while the other column contains the input field but i did not succeed.
I wrote some CSS to create the desired layout. It works without changing the provided HTML.
You can add the missing name input from the image though.
The .details > input:first-child selects the Apply Now button and set a margin-left: calc(25% + 6px), so it has a left space matching the labels and is align with other inputs.
You might as well consider using an actual <button> tag for submit though. If you do so later, you can change this selector to .details > button:first-child.
Hope this will help!
Example:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
form {
width: 600px;
display: flex;
flex-direction: column;
gap: 9px;
padding: 30px;
}
.details {
display: flex;
justify-content: flex-start;
align-items: center;
gap: 6px;
}
.details > label:first-child {
width: 25%;
display: flex;
justify-content: flex-end;
}
.details > input#date {
margin-right: 30px;
}
.details > input:first-child {
margin-left: calc(25% + 6px);
padding: 3px 6px;
}
<form>
<div class="details">
<label for="email">E-mail:</label>
<input type="email" id="email" name="email" />
</div>
<div class="details">
<label for="tel">Telephone Number:</label>
<input type="tel" id="tel" name="tel" />
</div>
<div class="details">
<label for="position">Position:</label>
<input type="text" id="position" name="position" />
<input type="radio" name="availability" id="Part-Time" value="Part-Time" />
<label for="radio">Part-Time</label>
<input type="radio" name="availability" id="Full-Time" value="Full-Time" />
<label for="radio">Full-Time</label>
</div>
<div class="details">
<label for="date">Date:</label>
<input type="date" id="date" name="date" />
<input type="checkbox" name="AM" id="AM" value="AM" />
<label for="checkbox">AM</label>
<input type="checkbox" name="PM" id="PM" value="PM" />
<label for="radio">PM</label>
</div>
<div class="details">
<label for="yearsofexperience">Years of Experience:</label>
<input type="text" id="yearsofexperience" name="yearsofexperience" />
</div>
<div class="details"></div>
<div class="details">
<label for="experience">Experience:</label>
<textarea name="experience" id="experience" rows="1" cols="20">
Worked 5 years at Bayshore Veterinarian Services</textarea
>
</div>
<div class="details">
<input type="submit" value="Apply Now" />
</div>
</form>
I have 3 childs divs with each possessing a button element inside like showed by the following picture:
Code:
body {
background-color: white;
}
input,
select,
textarea {
width: 100%;
padding: 6px;
border: 1px solid #ccc;
border-radius: 5px;
}
label {
padding: 12px 12px 12px 0;
display: flex;
flex-direction: column;
}
.Order_Create_Ship_Stock>div {
display: table-cell;
width: 10%;
margin: 5px;
border: solid;
}
.Order_Create_Ship_Stock {
display: inline-table;
border-spacing: 10px;
}
.Order_Create,
.Order_Ship,
.Order_Store {
border-radius: 5px;
background-color: #f2f2f2;
padding: 10px;
}
#SubmitCreateOrder,
#SubmitShipOrder,
#SubmitStoreOrder {
transition-duration: 0.4s;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
color: black;
border: 2px solid #4caf50;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
display: flex;
flex-direction: column;
margin: auto;
}
#SubmitCreateOrder:hover {
background-color: #4caf50;
color: white;
}
#SubmitShipOrder:hover {
background-color: #4caf50;
color: white;
}
#SubmitStoreOrder:hover {
background-color: #4caf50;
color: white;
}
<div id="OrderCreateShipStock" class="Order_Create_Ship_Stock">
<div id="OrderCreate" class="Order_Create">
<form onsubmit="App.createOrder(); return false">
<label for="BarcodeInput">
<span>Barcode</span>
<input
name="BarcodeInput"
id="Barcode"
class="Barcorde"
type="text"
placeholder="Order's Barcode..."
/>
</label>
<label for="OwnerInput">
<span>Owner</span>
<input
name="OwnerInput"
id="Owner"
class="Owner"
type="text"
placeholder="Owner of the product..."
/>
</label>
<label for="ProductListInput">
<span>Product list</span>
<input
name="ProductListInput"
id="ProductList"
class="Product_List"
type="text"
placeholder="Product list of the order...."
/>
</label>
<label for="ExpirationDateInput">
<span>Expiration date</span>
<input
name="ExpirationDateInput"
id="ExpirationDate"
class="Expiration_Date"
type="date"
/>
</label>
<label for="TemperatureMinimalInput">
<span>Temperature minimal</span>
<input
name="TemperatureMinimalInput"
id="TemperatureMinimal"
class="Temperature_Minimal"
type="number"
placeholder="Minimal temperature of order's environment..."
/>
</label>
<label for="TemperatureMaximalInput">
<span>Temperature maximal</span>
<input
name="TemperatureMaximalInput"
id="TemperatureMaximal"
class="Temperature_Maximal"
type="number"
placeholder="Maximal temperature of order's environment..."
/>
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select name="IOTDeviceInput" id="IOTDevice" class="IOT_Device">
<option value="">---Please select an IOT Device---</option>
</select>
</label>
<label for="FinalDestinationInput">
<span>Final destination</span>
<input
name="FinalDestinationInput"
id="FinalDestination"
class="Final_Destination"
type="text"
placeholder="Order's final destination..."
/>
</label>
<button id="SubmitCreateOrder" class="Submit_Create_Order" type="submit">
Create Order
</button>
</form>
</div>
<div id="OrderShip" class="Order_Ship">
<form onsubmit="App.ShipOrder(); return false">
<label for="OrderIDInput">
<span>OrderID</span>
<input
name="OrderIDInput"
id="OrderID"
class="Order_ID"
type="text"
placeholder="Order's ID"
/>
</label>
<label for="ActualLocationInput">
<span>Actual location</span>
<input
name="ActualLocationInput"
id="ActualLocation"
class="Actual_Location_Input"
type="text"
placeholder="Order's actual location"
/>
</label>
<label for="ActualTemperatureInput">
<span>Actual temperature</span>
<input
name="ActualTemperatureInput"
id="ActualTemperature"
class="Actual_Temperature"
type="text"
placeholder="Order's actual environment temperature"
/>
</label>
<label for="CurrentCounterpartyInput">
<span>Counterparty</span>
<input
name="CurrentCounterpartyInput"
id="CurrentCounterparty"
class="Current_Counterparty"
type="text"
placeholder="Order's current counterparty"
/>
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select
name="IOTDeviceInput"
id="IOTDevice"
class="IOT_Device_Input"
>
</select>
</label>
<label for="AnticipatedDateInput">
<span>Anticipated date</span>
<input
name="AnticipatedDateInput"
id="AnticipatedDate"
class="Anticipated_Date"
type="date"
/>
</label>
<label for="DestinationInput">
<span>Destination</span>
<input
name="DestinationInput"
id="Destination"
class="Destination_"
type="text"
placeholder="Order's destination"
/>
</label>
<button id="SubmitShipOrder" class="Submit_Ship_Order" type="submit">
Ship Order
</button>
</form>
</div>
<div id="OrderStore" class="Order_Store">
<form onsubmit="App.storeOrder(); return false">
<label for="OrderIDInput">
<span>OrderID</span>
<input
name="OrderIDInput"
id="OrderID"
class="Order_ID"
type="text"
placeholder="Order's ID"
/>
</label>
<label for="ActualLocationInput">
<span>Actual location</span>
<input
name="ActualLocationInput"
id="ActualLocation"
class="Actual_Location_Input"
type="text"
placeholder="Order's actual location"
/>
</label>
<label for="ActualTemperatureInput">
<span>Actual temperature</span>
<input
name="ActualTemperatureInput"
id="ActualTemperature"
class="Actual_Temperature"
type="text"
placeholder="Order's actual environment temperature"
/>
</label>
<label for="CurrentCounterpartyInput">
<span>Counterparty</span>
<input
name="CurrentCounterpartyInput"
id="CurrentCounterparty"
class="Current_Counterparty"
type="text"
placeholder="Order's current counterparty"
/>
</label>
<!-- Your Stuff -->
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select
name="IOTDeviceInput"
id="IOTDevice"
class="IOT_Device_Input"
>
<option value="">---Please select an IOT Device---</option>
</select>
</label>
<button id="SubmitStoreOrder" class="Submit_Store_Order" type="submit">
Store Order
</button>
</form>
</div>
</div>
I basically want that the Ship Order and Store Order button are positioned at the same height. I followed the advice from some other posts like using justify-content: flex-end, but they didn't work...
I thank in advance anybody who will help me :).
It's probably not the best solution, but working.
So you can play a bit with it.
I added
.Order_Create,
.Order_Ship,
.Order_Store {
...
padding: 20px 10px;
position:relative;
}
and
#SubmitCreateOrder,
#SubmitShipOrder,
#SubmitStoreOrder {
...
margin: auto;
position: absolute;
bottom: 5px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
}
body {
background-color: white;
}
input,
select,
textarea {
width: 100%;
padding: 6px;
border: 1px solid #ccc;
border-radius: 5px;
}
label {
padding: 12px 12px 12px 0;
display: flex;
flex-direction: column;
}
.Order_Create_Ship_Stock>div {
display: table-cell;
width: 10%;
margin: 5px;
border: solid;
}
.Order_Create_Ship_Stock {
display: inline-table;
border-spacing: 10px;
}
.Order_Create,
.Order_Ship,
.Order_Store {
border-radius: 5px;
background-color: #f2f2f2;
padding: 20px 10px;
position:relative;
}
#SubmitCreateOrder,
#SubmitShipOrder,
#SubmitStoreOrder {
transition-duration: 0.4s;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
color: black;
border: 2px solid #4caf50;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
margin: auto;
position: absolute;
bottom: 5px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
}
#SubmitCreateOrder:hover {
background-color: #4caf50;
color: white;
}
#SubmitShipOrder:hover {
background-color: #4caf50;
color: white;
}
#SubmitStoreOrder:hover {
background-color: #4caf50;
color: white;
}
<div id="OrderCreateShipStock" class="Order_Create_Ship_Stock">
<div id="OrderCreate" class="Order_Create">
<form onsubmit="App.createOrder(); return false">
<label for="BarcodeInput">
<span>Barcode</span>
<input
name="BarcodeInput"
id="Barcode"
class="Barcorde"
type="text"
placeholder="Order's Barcode..."
/>
</label>
<label for="OwnerInput">
<span>Owner</span>
<input
name="OwnerInput"
id="Owner"
class="Owner"
type="text"
placeholder="Owner of the product..."
/>
</label>
<label for="ProductListInput">
<span>Product list</span>
<input
name="ProductListInput"
id="ProductList"
class="Product_List"
type="text"
placeholder="Product list of the order...."
/>
</label>
<label for="ExpirationDateInput">
<span>Expiration date</span>
<input
name="ExpirationDateInput"
id="ExpirationDate"
class="Expiration_Date"
type="date"
/>
</label>
<label for="TemperatureMinimalInput">
<span>Temperature minimal</span>
<input
name="TemperatureMinimalInput"
id="TemperatureMinimal"
class="Temperature_Minimal"
type="number"
placeholder="Minimal temperature of order's environment..."
/>
</label>
<label for="TemperatureMaximalInput">
<span>Temperature maximal</span>
<input
name="TemperatureMaximalInput"
id="TemperatureMaximal"
class="Temperature_Maximal"
type="number"
placeholder="Maximal temperature of order's environment..."
/>
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select name="IOTDeviceInput" id="IOTDevice" class="IOT_Device">
<option value="">---Please select an IOT Device---</option>
</select>
</label>
<label for="FinalDestinationInput">
<span>Final destination</span>
<input
name="FinalDestinationInput"
id="FinalDestination"
class="Final_Destination"
type="text"
placeholder="Order's final destination..."
/>
</label>
<button id="SubmitCreateOrder" class="Submit_Create_Order" type="submit">
Create Order
</button>
</form>
</div>
<div id="OrderShip" class="Order_Ship">
<form onsubmit="App.ShipOrder(); return false">
<label for="OrderIDInput">
<span>OrderID</span>
<input
name="OrderIDInput"
id="OrderID"
class="Order_ID"
type="text"
placeholder="Order's ID"
/>
</label>
<label for="ActualLocationInput">
<span>Actual location</span>
<input
name="ActualLocationInput"
id="ActualLocation"
class="Actual_Location_Input"
type="text"
placeholder="Order's actual location"
/>
</label>
<label for="ActualTemperatureInput">
<span>Actual temperature</span>
<input
name="ActualTemperatureInput"
id="ActualTemperature"
class="Actual_Temperature"
type="text"
placeholder="Order's actual environment temperature"
/>
</label>
<label for="CurrentCounterpartyInput">
<span>Counterparty</span>
<input
name="CurrentCounterpartyInput"
id="CurrentCounterparty"
class="Current_Counterparty"
type="text"
placeholder="Order's current counterparty"
/>
</label>
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select
name="IOTDeviceInput"
id="IOTDevice"
class="IOT_Device_Input"
>
</select>
</label>
<label for="AnticipatedDateInput">
<span>Anticipated date</span>
<input
name="AnticipatedDateInput"
id="AnticipatedDate"
class="Anticipated_Date"
type="date"
/>
</label>
<label for="DestinationInput">
<span>Destination</span>
<input
name="DestinationInput"
id="Destination"
class="Destination_"
type="text"
placeholder="Order's destination"
/>
</label>
<button id="SubmitShipOrder" class="Submit_Ship_Order" type="submit">
Ship Order
</button>
</form>
</div>
<div id="OrderStore" class="Order_Store">
<form onsubmit="App.storeOrder(); return false">
<label for="OrderIDInput">
<span>OrderID</span>
<input
name="OrderIDInput"
id="OrderID"
class="Order_ID"
type="text"
placeholder="Order's ID"
/>
</label>
<label for="ActualLocationInput">
<span>Actual location</span>
<input
name="ActualLocationInput"
id="ActualLocation"
class="Actual_Location_Input"
type="text"
placeholder="Order's actual location"
/>
</label>
<label for="ActualTemperatureInput">
<span>Actual temperature</span>
<input
name="ActualTemperatureInput"
id="ActualTemperature"
class="Actual_Temperature"
type="text"
placeholder="Order's actual environment temperature"
/>
</label>
<label for="CurrentCounterpartyInput">
<span>Counterparty</span>
<input
name="CurrentCounterpartyInput"
id="CurrentCounterparty"
class="Current_Counterparty"
type="text"
placeholder="Order's current counterparty"
/>
</label>
<!-- Your Stuff -->
<label for="IOTDeviceInput">
<span>IOT Device</span>
<select
name="IOTDeviceInput"
id="IOTDevice"
class="IOT_Device_Input"
>
<option value="">---Please select an IOT Device---</option>
</select>
</label>
<button id="SubmitStoreOrder" class="Submit_Store_Order" type="submit">
Store Order
</button>
</form>
</div>
</div>
Im using flex to format input on a row format. But right now im trying to put label on top of those inputs and its not working. Im tried using display block and floating left or right but still remains on the left side. How should i style label so it floats to the top of those inputs?
This is the snippet:
.box {
padding-top: 1rem;
}
.inside-box {
max-width: 51rem;
margin: 0 auto;
}
.form-group {
display: flex;
flex-direction: column;
}
.row {
display: flex;
}
.razao-social-content {
flex: 2 1 auto;
/* grow shrink basis */
}
.rua-content {
flex: 6 1 auto;
}
.municipio-content {
flex: 4 1 auto;
}
.numero-content {
flex: auto 1 auto;
}
.bairro-content {
flex: 4 1 auto;
}
.telefone-content {
flex: 1 1 auto;
}
.email-content {
flex: 1 1 auto;
}
.categoria-content {
flex: 2 1 auto;
}
.controlador-content {
flex: 2 1 auto;
}
label {}
<div class="box">
<div class="inside-box">
<form action="" class="form-group">
<div class="row">
<label class="lb" for="name">Razão Social</label>
<input class="razao-social-content" type="text" id="name" placeholder="Informe o seu nome" required>
<label class="lb" for="cnpj_distribuidor">CNPJ</label>
<input class="cnpj-content" type="text" id="cnpj_distribuidor" placeholder="CNPJ" required>
</div>
<div class="row">
<label for="rua">Rua</label>
<input class="rua-content" type="text" id="rua" placeholder="Nome da rua" required>
<label for="municipio">Município</label>
<input class="municipio-content" type="text" id="municipio" placeholder="Nome do Município" required>
<label for="numero">Número</label>
<input class="numero-content" type="text" id="numero" placeholder="Número da Residência" required>
</div>
<div class="row">
<label for="bairro">Bairro</label>
<input class="bairro-content" type="text" id="bairro" placeholder="Nome do Bairro" required>
<label for="uf">Estado</label>
<input class="uf" type="text" id="uf" placeholder="Estado" required>
<label for="cep">CEP</label>
<input class="cep-content" type="text" id="cep" placeholder="CEP" required>
</div>
<div class="row">
<label for="telefone1">Telefone</label>
<input class="telefone-content" type="text" id="telefone1" placeholder="Telefone" required>
<input class="telefone-content" type="text" id="telefone2" placeholder="Telefone" required>
<input class="telefone-content" type="text" id="telefone3" placeholder="Telefone" required>
<input class="telefone-content" type="text" id="telefone4" placeholder="Telefone" required>
</div>
<div class="row">
<label for="email1">Email</label>
<input class="email-content" type="text" id="email1" placeholder="Email" required>
<input class="email-content" type="text" id="email2" placeholder="Email" required>
<input class="email-content" type="text" id="email3" placeholder="Email" required>
<input class="email-content" type="text" id="email4" placeholder="Email" required>
</div>
<div class="row">
<label for="categoria">Categorias</label>
<input class="categoria-content" type="text" id="categoria" placeholder="Informe as Categorias" required>
<label for="data_constituicao">Data Da Constituição</label>
<input class="data-content" type="date" id="data_constituicao" placeholder="Data da Constituição" required>
<label for="data_cvm">Data da CVM</label>
<input class="data-content" type="date" id="data_cvm" placeholder="Data do CVM" required>
</div>
<div class="row">
<label for="controlador">Controlador</label>
<input class="controlador-content" type="text" id="controlador" placeholder="Nome do Controlador" required>
<label for="cnpj_controlador">CNPJ</label>
<input class="cnpj-content" type="text" id="cnpj_controlador" placeholder="CNPJ" required>
</div>
</form>
</div>
</div>
This image link shows how I want it to be
https://www.figma.com/file/nuLJYzwr2LtoJxt4rPKDaI/Untitled?node-id=0%3A1
Just wrap label and input inside a div and add :
.row > div {
display: flex;
flex-direction: column;
}
Im making this webpage and I am almost done its just I have a question regarding the background because the second one is the one that its supposed to look like and the first one is mine. I just want to get rid of that white space in between and have like outer padding. Ive tried playing around with padding and it didnt work for some reason heres the link (https://imgur.com/a/FlVN538) also heres my code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cycling Tours</title>
<style>
body {
font-family: Verdana, sans-serif;
}
form {
width: 700px;
margin: 0 auto;
}
h1 {
text-align: center;
}
fieldset {
background-color: #4681A4;
min-width: 700px;
max-width: 700px;
border: solid white 2px;
}
legend {
color: white;
text-indent: 2em;
}
label {
font-size: 0.9em;
}
textarea {
display: block;
width: 80%;
height: 100px;
min-width: 50%;
max-width: 90%;
}
.buttonstyle {
text-transform: uppercase;
font-weight: bold;
background-color:#FFFFE6;
}
input[type=text], input[type=email], input[type=phonenumber] {
background-color:#ffffe6;
}
</style>
</head>
<body>
<h1>Fall 2018 Reviews</h1>
<form method="POST" action="https://csunix.mohawkcollege.ca/tooltime/showit.pl">
<!--<input type="hidden" name="formname" value="Donation Form">
<input type="hidden" name="windowname" value="Donation">-->
<fieldset id="aboutyou">
<legend>About you(optional)</legend>
<label for="aboutyou">I usually prefer to trips around this time of year(select all that apply)</label>
<br>
<select name="seasons" id="seasons" size="4" multiple>
<option>Winter</option>
<option>Spring</option>
<option>Summer</option>
<option>Fall</option>
</select>
<br>
<label for="firstname">First Name</label>
<input type="text" name="firstname" id="firstname" >
<br>
<label for="lastname">Last Name</label>
<input type="text" name="lastname" id="lastname">
<br>
<label for="phonenumber">Phone Number</label>
<input type="phonenumber" name="phonenumber" id="phonenumber" placeholder="123-456-7890" size="12">
<br>
<label for="email">Email Address</label>
<input type="email" name="email" id="email" placeholder="name#example.com" size="40">
</fieldset>
<fieldset>
<legend>Trip Reviews</legend>
<div id="trails">
<label for="trailchoice"></label>
<select name="trailchoice" id="trailchoice">
<option value="Alberta Rural">Alberta Rural</option>
<option value="B.C. Coast">B.C. Coast</option>
<option value="Ontario Lake Superior">Ontario Lake Superior</option>
<option value="PEI">PEI</option>
<option value="Nova Scotia Cabot Trail">Nova Scotia Cabot Trail</option>
</select>
<div id="daylength">
<label for="days"></label>
<select name="days" id="days">
<option value="5 days">5 days</option>
<option value="7 days">7 days</option>
<option value="10 days">10 days</option>
<option value="14 days">14 days</option>
</select>
<div id="credit">
<input type="radio" id="fourstars" value="4" checked>
<label for="fourstars"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"></label>
<br>
<input type="radio" name="threestars" id="threestars" value="3">
<label for="threestarts"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"></label>
<br>
<input type="radio" name="twostars" id="twostars" value="2">
<label for="twostars"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"></label>
<br>
<input type="radio" name="onestar" id="onestar" value="1">
<label for="onestar"><img src="l5mg/wheel_sm.jpg"></label>
<br>
<label for="feedback">comments</label>
<textarea name="feedback" id="feedback" rows="6" cols="45" placeholder="Place feedback here..."></textarea>
</div>
</select>
</div>
</fieldset>
<fieldset id="fsfeedback">
<legend>I would be interested in these trips:(check all that apply)</legend>
<input type="checkbox" name="Sea or Lake Coast" id="SLC" value="Sea or Lake coast">
<label for="SLC">Sea or lake coast</label>
<br>
<input type="checkbox" name="Rural" id="Rural" value="Rural">
<label for="Rural">Rural</label>
<br>
<input type="checkbox" name="Mountain" id="Mountain" value="Mountains">
<label for="Mountain">Mountains</label>
<br>
<input type="checkbox" name="other" id="other" value="other">
<label for="other" >Other (Please Specify)</label><label for="other"></label>
<input type="text" name="specified" id="specified">
</fieldset>
<input type="submit" value="Send Review" class="buttonstyle">
<input type="reset" value="Cancel" class="buttonstyle">
</form>
</body>
</html>
body {
font-family: Verdana, sans-serif;
}
form {
background: #4681A4;
width: 700px;
margin: 0 auto;
padding-top: 10px;
padding-bottom: 10px;
}
h1 {
text-align: center;
}
fieldset {
border: solid white 2px;
margin: 5px;
margin-bottom: 20px;
}
legend {
color: white;
text-indent: 2em;
}
label {
font-size: 0.9em;
}
textarea {
display: block;
width: 80%;
height: 100px;
min-width: 50%;
max-width: 90%;
}
.buttonstyle {
text-transform: uppercase;
font-weight: bold;
background-color: #FFFFE6;
}
input[type=text],
input[type=email],
input[type=phonenumber] {
background-color: #ffffe6;
}
.buttons {
margin-left: 19px;
}
<h1>Fall 2018 Reviews</h1>
<form method="POST" action="https://csunix.mohawkcollege.ca/tooltime/showit.pl">
<!--<input type="hidden" name="formname" value="Donation Form">
<input type="hidden" name="windowname" value="Donation">-->
<fieldset id="aboutyou">
<legend>About you(optional)</legend>
<label for="aboutyou">I usually prefer to trips around this time of year(select all that apply)</label>
<br>
<select name="seasons" id="seasons" size="4" multiple>
<option>Winter</option>
<option>Spring</option>
<option>Summer</option>
<option>Fall</option>
</select>
<br>
<label for="firstname">First Name</label>
<input type="text" name="firstname" id="firstname">
<br>
<label for="lastname">Last Name</label>
<input type="text" name="lastname" id="lastname">
<br>
<label for="phonenumber">Phone Number</label>
<input type="phonenumber" name="phonenumber" id="phonenumber" placeholder="123-456-7890" size="12">
<br>
<label for="email">Email Address</label>
<input type="email" name="email" id="email" placeholder="name#example.com" size="40">
</fieldset>
<fieldset>
<legend>Trip Reviews</legend>
<div id="trails">
<label for="trailchoice"></label>
<select name="trailchoice" id="trailchoice">
<option value="Alberta Rural">Alberta Rural</option>
<option value="B.C. Coast">B.C. Coast</option>
<option value="Ontario Lake Superior">Ontario Lake Superior</option>
<option value="PEI">PEI</option>
<option value="Nova Scotia Cabot Trail">Nova Scotia Cabot Trail</option>
</select>
<div id="daylength">
<label for="days"></label>
<select name="days" id="days">
<option value="5 days">5 days</option>
<option value="7 days">7 days</option>
<option value="10 days">10 days</option>
<option value="14 days">14 days</option>
</select>
<div id="credit">
<input type="radio" id="fourstars" value="4" checked>
<label for="fourstars"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"><img
src="l5mg/wheel_sm.jpg"></label>
<br>
<input type="radio" name="threestars" id="threestars" value="3">
<label for="threestarts"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"></label>
<br>
<input type="radio" name="twostars" id="twostars" value="2">
<label for="twostars"><img src="l5mg/wheel_sm.jpg"><img src="l5mg/wheel_sm.jpg"></label>
<br>
<input type="radio" name="onestar" id="onestar" value="1">
<label for="onestar"><img src="l5mg/wheel_sm.jpg"></label>
<br>
<label for="feedback">comments</label>
<textarea name="feedback" id="feedback" rows="6" cols="45" placeholder="Place feedback here..."></textarea>
</div>
</select>
</div>
</fieldset>
<fieldset id="fsfeedback">
<legend>I would be interested in these trips:(check all that apply)</legend>
<input type="checkbox" name="Sea or Lake Coast" id="SLC" value="Sea or Lake coast">
<label for="SLC">Sea or lake coast</label>
<br>
<input type="checkbox" name="Rural" id="Rural" value="Rural">
<label for="Rural">Rural</label>
<br>
<input type="checkbox" name="Mountain" id="Mountain" value="Mountains">
<label for="Mountain">Mountains</label>
<br>
<input type="checkbox" name="other" id="other" value="other">
<label for="other">Other (Please Specify)</label><label for="other"></label>
<input type="text" name="specified" id="specified">
</fieldset>
<div class="buttons">
<input type="submit" value="Send Review" class="buttonstyle">
<input type="reset" value="Cancel" class="buttonstyle">
</div>
</form>
I'm horrible with CSS and was wondering how I could center text over input fields.
This is what I have:
.fieldset{
border: 1px solid rgb(255,232,57);
width: 400px;
margin:0px auto;
text-align:center;
}
what I get:
html:
<div class="fieldset" id="Display">
<form id="addNew" action="/RxCard/AddAccount" enctype="multipart/form-data" method="post" novalidate="novalidate"><input name="__RequestVerificationToken" type="hidden" value="gz4TQWfHkdBy6ClvES3plFN_RK4J8F3neJdgvSzTf3_eJX_pnvPvbN71UR8jrBlysSPWi3jHmx05s7svwr82TF1hmGwSDb5EgsODmmE6H6k1"> <fieldset>
<div class="form">
<label id="lblAccountName">Account Name</label>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="Pharmacy.AccountName"></span>
<input name="Pharmacy.AccountName" id="Pharmacy_AccountName" type="text" value="" data-val-required="The account name is required." data-val="true">
<label id="lblAddress" style="margin: 5px;">Address</label>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="Pharmacy.Address"></span>
<input name="Pharmacy.Address" id="Pharmacy_Address" type="text" value="" data-val-required="The address is required." data-val="true">
<label id="lblCity" style="margin: 5px;">City</label>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="Pharmacy.City"></span>
<input name="Pharmacy.City" id="Pharmacy_City" type="text" value="" data-val-required="The city is required." data-val="true">
<label id="lblState" style="margin: 5px;">State</label>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="Pharmacy.State"></span>
<input name="Pharmacy.State" id="Pharmacy_State" type="text" value="" data-val-required="The state is required." data-val="true">
<label id="lblZip" style="margin: 5px;">Zip</label>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="Pharmacy.ZipCode"></span>
<input name="Pharmacy.ZipCode" id="Pharmacy_ZipCode" type="text" value="" data-val-required="The zip code is required." data-val="true" data-val-regex-pattern="^[-,0-9]+$" data-val-regex="Zip code can only contain numeric values.">
<label id="lblPhoneNumber" style="margin: 5px;">Phone Number (optional)</label>
<span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="Pharmacy.PhoneNumber"></span>
<input name="txtArea" class="valid" id="txtArea" aria-invalid="false" aria-describedby="txtArea-error" style="width: 5em; float: left;" onkeyup="tabout(this,'txtPrefix');" type="text" maxlength="3" value="">
<input name="txtPrefix" class="valid" id="txtPrefix" aria-invalid="false" aria-describedby="txtPrefix-error" style="width: 5em; float: left;" onkeyup="tabout(this,'txtSuffix');" type="text" maxlength="3" value="">
<input name="txtSuffix" class="valid" id="txtSuffix" aria-invalid="false" aria-describedby="txtSuffix-error" style="width: 5em; float: left;" type="text" maxlength="4" value="">
</div>
</fieldset>
<input type="submit" value="Save">
<input type="submit" value="Cancel">
</form> </div>
update:
I think I might have solved it by replacing "block" with a new class called "form" with properties "width:200px;" and "margin:0 auto;"? but I'd still like to get an opinion from the experts.
I'm a huge advocate of flexbox, but this is just me :)
form {
display: flex;
flex-direction: column;
align-items: center;
}
input {
width: 200px; /* SET THIS TO WHATEVER WIDTH */
}
input[type="submit"] {
margin-top: 25px;
}
/* BASIC STYLING */
<form action="#" method="post">
<label for="name">Text Input:</label>
<input type="text" name="name" id="name" value="" tabindex="1" />
<label for="name">Text Input:</label>
<input type="text" name="name" id="name" value="" tabindex="1" />
<label for="name">Text Input:</label>
<input type="text" name="name" id="name" value="" tabindex="1" />
<input type="submit" value="Submit" />
</form>
try this
input {
width: 100%;
}
UPD_
You wanted so much? It's simple:
label {
display: block;
}
input[type=text] {
margin:0px auto;
/* OR */
/* width: 100%; */
}
see here - https://jsfiddle.net/7znty0vb/2/