What I want is for some of the input fields to have two place holder in given image below exactly same like picture given below. I have tried a lot but nothing works.
<form class="subscribe-form">
<div class="personal-information">
<select name = "country" id="country">
<span>Country</span>
<option value ="US" >US</option>
<option value = "India">India</option>
<option value = "Malaysia">Malaysia</option>
</select>
<select name ="cardType" id="cardType">
<option value = "Amex">Amex</option>
<option value = "Visa">Visa</option>
<option value = "Master card">Master card</option>
</select>
<input type="text" id="cnum" name="address" placeholder="Card Number"/>
<div class="date-container">
<div class="card-data">
<input type="text" id="expyear" name="expyear" placeholder="Expiry Date">
<input type="text" id="csc" name="csc" placeholder="CSC"/>
</div>
<div class="name-data">
<input type="text" id="fname" name="firstname" placeholder="First Name"/>
<input type="text" id="lname" name="lastname" placeholder="Last Name"/>
</div>
</div>
</div>
<div class="Billing-deatails">
<h3>Billing Address</h3>
<input type="text" id="line1" name="line2" placeholder="Address Line 1"/>
<input type="text" id="line2" name="line2" placeholder="Address Line 2"/>
<input type="text" id="Town/city" name="Town/city" placeholder="Town/city"/>
<div class="numberType">
<select name = "country" id="country2">
<option value ="US" >US</option>
<option value = "India">India</option>
<option value = "Malaysia">Malaysia</option>
</select>
<input type="text" id="number" name="number" placeholder="Postcode"/>
</div>
</div>
<div class="contact-information">
<h5>Contact Information</h5>
<div class="number-info">
<select name = "phoneType" id="phoneType">
<option value ="Mobile" >Mobile</option>
</select>
<input type="text" id="number" name="number" placeholder="+65"/>
</div>
<input type="email" id="email" name="email" placeholder="Email Address"/>
</div>
</div>
<div class="subscribe-btn">
<button type="submit">SUBSCRIBE</button>
</div>
</form>
There are no multiple placeholder things in HTML. You have to use the Label with custom CSS.You can try the below code but I have done it for only one Select box you can use the same for others. You can edit the CSS as per your convenience.
.select-wrap
{
border: 1px solid #777;
border-radius: 4px;
margin-bottom: 10px;
padding: 0 5px 5px;
width:200px;
background-color:#ebebeb;
}
.select-wrap label
{
font-size:10px;
text-transform: uppercase;
color: #777;
padding: 2px 8px 0;
}
select
{
background-color: #ebebeb;
border:0px;
}
<div class="select-wrap">
<label>Country</label>
<select name = "country" id="country" style="width: 100%;">
<span>Country</span>
<option value ="US" >US</option>
<option value = "India">India</option>
<option value = "Malaysia">Malaysia</option>
</select>
</div>
Related
i'm a french begginer (so excuse the fact that some part of it are in french, if it's a problem i can translate, also i know my code can be more clean so if you have any idea dont hesitate!).
I'm coding a form for a project and i would like to align all my text like this :
but my page look like this for the moment :
fieldset {
width: 900px;
}
em {
color: red;
}
#demande {
height: 200px;
width: 800px;
background-color: #EAEAEA;
}
placeholder {
text-align: top;
}
strong {
color: #C1D58D;
}
input {
margin-left: 100px;
}
<fieldset>
<legend><b>INFORMATIONS PERSONNELLES</b></legend>
<form method="get">
<label for "Nom">Nom<em>*</em> :</label>
<input type="text" name="Nom" id="text" required />
</form>
</br>
</br>
<form method="get">
<label for "Prénom">Prénom<em>*</em> :</label>
<input type="text" name="Prénom" id="text" required />
</form>
</br>
</br>
<form method="get">
<form method="get">
<label><strong> Votre sexe</strong><em>*</em> :</label> </br>
<input type="radio" name="Sexe" id="Fille" /> <label for="Fille">Fille</label>
<input type="radio" name="Sexe" id="Garçon" /> <label for="Garçon">Garçon</label>
<input type="radio" name="Sexe" id="Autre" /> <label for="Autre">Autre</label>
</form>
</br>
</br>
<label> Année<em>*</em> :</label>
<input type="number" name="Année" id="Année" placeholder="Exemple : 1987" />
</form>
</br>
</br>
<form method="get">
<label for "pays"> Pays<em>*</em> :</label>
<select name="pays" id="pays" required>
<optgroup label="Europe">
<option value="france">France</option>
<option value="espagne">Espagne</option>
<option value="royaume-uni">Royaume-Uni</option>
<option value="italie">Italie</option>
</optgroup>
<optgroup label="Amérique">
<option value="canada">Canada</option>
<option value="etats-unis">États-Unis</option>
</optgroup>
<optgroup label="Asie">
<option value="chine">Chine</option>
<option value="japon">Japon</option>
</optgroup>
</select>
</br>
</br>
</form>
<h3>Les champs marqués par <em>*</em> sont obligatoires</h3>
</fieldset>
</br>
<form method="get">
<input type="submit" name="Envoyer" value="Annuler" />
<input type="submit" name="Envoyer" value="Envoyer" />
</form>
```
i know i could creat an id for every then edit it with css but i was wondering if there was a best way to do it (a more efficient way)
One easy solution is the use of CSS-Grid. I removed the form tags so that all elements are direct children of the fieldset.
As such I can declared fieldset { display: grid; } to apply the grid.
Next I apply a 2 column layout where the first column takes as much space as needed and the second column the remaining space with: fieldset { grid-template-columns: min-content auto;.
To space the elements apart, you can use the grid-gap-property.
fieldset {
max-width: 900px;
display: grid;
grid-template-columns: min-content auto;
gap: 10px;
}
em {
color: red;
}
fieldset h3 {
grid-column: span 2;
}
<fieldset>
<legend><b>INFORMATIONS PERSONNELLES</b></legend>
<label for "Nom">Nom<em>*</em> :</label>
<input type="text" name="Nom" id="text" required />
<label for "Prénom">Prénom<em>*</em> :</label>
<input type="text" name="Prénom" id="text" required />
<label><strong> Votre sexe</strong><em>*</em> :</label>
<div class="radio-group">
<input type="radio" name="Sexe" id="Fille" /> <label for="Fille">Fille</label>
<input type="radio" name="Sexe" id="Garçon" /> <label for="Garçon">Garçon</label>
<input type="radio" name="Sexe" id="Autre" /> <label for="Autre">Autre</label>
</div>
<label> Année<em>*</em> :</label>
<input type="number" name="Année" id="Année" placeholder="Exemple : 1987" />
<label for "pays"> Pays<em>*</em> :</label>
<select name="pays" id="pays" required>
<optgroup label="Europe">
<option value="france">France</option>
<option value="espagne">Espagne</option>
<option value="royaume-uni">Royaume-Uni</option>
<option value="italie">Italie</option>
</optgroup>
<optgroup label="Amérique">
<option value="canada">Canada</option>
<option value="etats-unis">États-Unis</option>
</optgroup>
<optgroup label="Asie">
<option value="chine">Chine</option>
<option value="japon">Japon</option>
</optgroup>
</select>
<h3>Les champs marqués par <em>*</em> sont obligatoires</h3>
</fieldset>
<form method="get">
<input type="submit" name="Envoyer" value="Annuler" />
<input type="submit" name="Envoyer" value="Envoyer" />
</form>
I would like the labels for the inputs to be the same width allowing the inputs and labels to be like a table.
Kind of like two columns: 1 for the labels and 1 for the inputs
Code So Far:
th, td, table{border: 2px solid black;
border-collapse: collapse;
}
th, td{width: 100px}
table{width: 100%;
text-align: center;}
body{font-family: "Bradley's Hand", cursive;}
.label{display: inline-block;
width: 100px}
input{width: 200px;}
<body>
<h1>Add Transactions</h1>
<fieldset>
<legend>Use This Form To Add Transactions</legend>
<form action="add.php" method="post">
<label class="label" for="date">Transaction Date: </label>
<input type="date" name="date" required>
<br>
<br>
<label class="label" for="amount">Transaction Amount: </label>
<input type="number" name="amount" required>
<br>
<br>
<label class="label" for="merchant">Merchant: </label>
<select name="merchant" required>
<option value="" disable selected>Select One</option>
<option value="other">Other</option>
</select>
<br>
<br>
<label class="label" for="om">Other Merchant: </label>
<input type="text" name="om">
<br><br>
<label for="type" class="label">Transaction Type: </label>
<select name="type" required>
<option value="" disable selected>Select One</option>
<option value="other">Other</option>
</select>
<br>
<br>
<label for="ot" class="label">Other Transaction Type: </label>
<input type="text" name="ot">
<br><br>
<label for="source" class="label">Source: </label>
<select name="source" required>
<option value="" disable selected>Select One</option>
<option value="other">Other</option>
</select>
<br>
<br>
<label for="os" class="label">Other Source: </label>
<input type="text" name="os">
<br>
<br>
<input type="reset">
<input type="submit" value="Save Transaction">
</form>
</fieldset>
</body>
</htm>
Thanks!
P.S. I can give more details if I am not clear enough!
P.P.S. What I mean by
like a table
is like the structure. Not like an actual table with <table>
Easiest way to solve it: CSS-Grid. Will allow for full responsiveness and create a table like layout. to leave the buttons at the bottom as they where, I wrapped them inside an extra div.
body {
font-family: "Bradley's Hand", cursive;
}
form {
display: grid;
grid-template-columns: min-content auto;
grid-row-gap: 2em;
white-space: nowrap;
}
.last-row {
grid-column: span 2;
}
.last-row input {
width: 200px;
}
<body>
<h1>Add Transactions</h1>
<fieldset>
<legend>Use This Form To Add Transactions</legend>
<form action="add.php" method="post">
<label class="label" for="date">
Transaction Date:
</label>
<input type="date" name="date" required>
<label class="label" for="amount">
Transaction Amount:
</label>
<input type="number" name="amount" required>
<label class="label" for="merchant">
Merchant:
</label>
<select name="merchant" required>
<option value="" disable selected>
Select One
</option>
<option value="other">
Other
</option>
</select>
<label class="label" for="om">
Other Merchant:
</label>
<input type="text" name="om">
<label for="type" class="label">
Transaction Type:
</label>
<select name="type" required>
<option value="" disable selected>
Select One
</option>
<option value="other">
Other
</option>
</select>
<label for="ot" class="label">
Other Transaction Type:
</label>
<input type="text" name="ot">
<label for="source" class="label">Source: </label>
<select name="source" required>
<option value="" disable selected>
Select One
</option>
<option value="other">
Other
</option>
</select>
<label for="os" class="label">Other Source: </label>
<input type="text" name="os">
<div class="last-row">
<input type="reset">
<input type="submit" value="Save Transaction">
</div>
</form>
</fieldset>
</body>
</htm>
(Image: https://imgur.com/a/xVxxNz1) So, as you can see, the tag is not getting the CSS properties correctly (like the name, age and number are). Could someone point out what is going wrong with my code so far? As I am new here on Stack Overflow, I would also like to know if I should have added more of my code on my post (I have just added what would be logically helpful, like the CSS styles and the tag itself). If I did that wrong, I will try to send you everything you need to help me.
#dropdown {
text-aling: center;
width: 100%;
border: 1px;
}
input,
button,
select,
textarea,
.form-control {
font-family: 'Open sans';
padding: 4px;
font-size: 70%;
margin-top: 6px;
opacity: 87%;
border: 1px;
padding-right: 10px;
padding-left: 10px;
background-color: #f9eedd;
}
<form id="survey-form">
<div>
<label id="name" for="name">Name<br>
<input type="text" name="name" id="name-label" value="" placeholder="Enter your name" required>
</label>
<br></br>
</div>
<div>
<label id="email">Email (<span class="optional">optional</span>) <br>
<input type="email" name="name" id="email-label" value="" placeholder="Enter your email" required="">
</label>
<br></br>
</div>
<div>
<label id="number">Number<br>
<input type="number" name="age" id="number-label" value="" placeholder="Age" min="10" max="99" required>
</label>
<br></br>
</div>
<p style="margin-top: -10px;">Define your current musical level:</p>
<select id="dropdown" name="role" required>
<option disabled="" selected="" value="">Select your level</option>
<option value="student">Student</option>
<option value="job">Full Time Job</option>
<option value="learner">Full Time Learner</option>
<option value="preferNo">Prefer not to say</option>
<option value="other">Other</option>
</select>
I saw that select tag also getting the CSS properties, but if you want to use the same width on the Select tag like the other fields, you need to remove the width from the dropdown. Also If you want to add some other style properties specifically only on the Select tag or any other specific tag, then you can write the CSS properties like the following way:
select#dropdown {
border: 1px solid transparent;
border-color: #fff transparent transparent transparent;
font-family: Arial;
text-align: center;
/* Write Other properties.....*/
}
Also here I am sharing one resource for your reference so that you can make a responsive form using CSS
you only specify border-width
add border: 1px solid red;
#dropdown {
text-aling: center;
width: 100%;
border: 1px solid red;
}
input,
button,
select,
textarea,
.form-control {
font-family: 'Open sans';
padding: 4px;
font-size: 70%;
margin-top: 6px;
opacity: 87%;
border: 1px;
padding-right: 10px;
padding-left: 10px;
background-color: #f9eedd;
}
<form id="survey-form">
<div>
<label id="name" for="name">Name<br>
<input type="text" name="name" id="name-label" value="" placeholder="Enter your name" required>
</label>
<br></br>
</div>
<div>
<label id="email">Email (<span class="optional">optional</span>) <br>
<input type="email" name="name" id="email-label" value="" placeholder="Enter your email" required="">
</label>
<br></br>
</div>
<div>
<label id="number">Number<br>
<input type="number" name="age" id="number-label" value="" placeholder="Age" min="10" max="99" required>
</label>
<br></br>
</div>
<p style="margin-top: -10px;">Define your current musical level:</p>
<select id="dropdown" name="role" required>
<option disabled="" selected="" value="">Select your level</option>
<option value="student">Student</option>
<option value="job">Full Time Job</option>
<option value="learner">Full Time Learner</option>
<option value="preferNo">Prefer not to say</option>
<option value="other">Other</option>
</select>
I have written a form in HTML and CSS. When i apply the display: inline-block property, some of the text goes to the next line, even though I am not using the <br/> tag. I also tried increasing the width of the fieldset element, but nothing changed.
My code:
fieldset {
background: lightyellow;
border: 10px solid yellow;
margin-bottom: 10px;
width: 720px;
}
label {
width: 180px;
display: inline-block;
text-align: right;
vertical-align: top;
}
#imp {
width: auto;
}
.imp {
text-align: center;
}
.imp {
text-align: right;
vertical-align: top;
}
<body>
<h1>Please Enter Your Details For Our Dating Website</h1>
<fieldset>
<legend>Your Face</legend>
<label for="image">Your Image:</label>
<input type="file" name="image" required id="image">
<br>
<label for="preview">Image Preview:</label>
<img id="preview" id="preview">
<br>
</fieldset>
<br>
<fieldset>
<legend>Your General Details</legend>
<label for="name">Name:</label>
<input type="text" placeholder="Your full name" name="name" id="name">
<br>
<label for="gender">Gender:</label>Male
<input type="radio" name="gender" value="male" id="gender">Female
<input type="radio" name="gender" name="female">
<br>
<label for="age">Age:</label>
<input type="number" id="age">
<br>
<label for="dob">Date of birth:</label>
<input type="date" id="dob">
<br>
<label for="color">Favorite color:</label>
<input type="color" id="color">
<br>
<label for="country">Which country:</label>
<select name="country" id="country">
<option value=""></option>
<option value="india">India</option>
<option value="china">China</option>
<option value="japan">Japan</option>
<option value="koria">Koria</option>
<option value="australia">Australia</option>
</select>
<br>
</fieldset>
<br>
<fieldset>
<legend>Your Indicators</legend>
<label for="height">Height:</label><span class="imp"> Short</span>
<input id="height " type="range" min="0" max="100" name="height"><span class="imp"> Tall<span><br>
<label for = "salary">Salary: </label><span class = "imp"> Poor</span>
<input id="salary " type="range" min="0" max="100" name="salary"><span class="imp"> Rich<span>
</fieldset>
<br>
<fieldset>
<legend>Your Contact Information</legend>
<label for = "email">Email: </label><input type = "email" name = "email"><br>
<label for = "mobile">Mobile: </label><input type = "tel" name = "telephone"><br>
<label for = id = "address">Address: <textarea name = "address" placeholder = "Input your address here." width = "360px" height = "50px"></textarea><br>
<label for = "contact" id = "imp">Method to contact you: </label>
<input id = "contact" type = "checkbox" name = "e_chat" value = "email">Email
<input id = "contact" type = "checkbox" name = "whatsapp" value = "whatsapp">Whatsapp
<input id = "contact" type = "checkbox" name = "in_app" value = "in_app">In-app chat
</fieldset>
<br><br>
<input type = "submit" value = "Submit"/>
</body>
Your have forgotten to close the label tag in your textarea text.
fieldset {
background: lightyellow;
border: 10px solid yellow;
margin-bottom: 10px;
width: 720px;
}
label {
width: 180px;
display: inline-block;
text-align: right;
vertical-align: top;
}
#imp {
width: auto;
}
.imp {
text-align: center;
}
.imp {
text-align: right;
vertical-align: top;
}
<body>
<h1>Please Enter Your Details For Our Dating Website</h1>
<fieldset>
<legend>Your Face</legend>
<label for="image">Your Image:</label>
<input type="file" name="image" required id="image">
<br>
<label for="preview">Image Preview:</label>
<img id="preview" id="preview">
<br>
</fieldset>
<br>
<fieldset>
<legend>Your General Details</legend>
<label for="name">Name:</label>
<input type="text" placeholder="Your full name" name="name" id="name">
<br>
<label for="gender">Gender:</label>Male
<input type="radio" name="gender" value="male" id="gender">Female
<input type="radio" name="gender" name="female">
<br>
<label for="age">Age:</label>
<input type="number" id="age">
<br>
<label for="dob">Date of birth:</label>
<input type="date" id="dob">
<br>
<label for="color">Favorite color:</label>
<input type="color" id="color">
<br>
<label for="country">Which country:</label>
<select name="country" id="country">
<option value=""></option>
<option value="india">India</option>
<option value="china">China</option>
<option value="japan">Japan</option>
<option value="koria">Koria</option>
<option value="australia">Australia</option>
</select>
<br>
</fieldset>
<br>
<fieldset>
<legend>Your Indicators</legend>
<label for="height">Height:</label><span class="imp"> Short</span>
<input id="height " type="range" min="0" max="100" name="height"><span class="imp"> Tall<span><br>
<label for = "salary">Salary: </label><span class = "imp"> Poor</span>
<input id="salary " type="range" min="0" max="100" name="salary"><span class="imp"> Rich<span>
</fieldset>
<br>
<fieldset>
<legend>Your Contact Information</legend>
<label for = "email">Email: </label><input type = "email" name = "email"><br>
<label for = "mobile">Mobile: </label><input type = "tel" name = "telephone"><br>
<label for ="address">Address:</label> <textarea name = "address" placeholder = "Input your address here." width = "360px" height = "50px"></textarea><br>
<label for = "contact" id = "imp">Method to contact you: </label>
<input id = "contact" type = "checkbox" name = "e_chat" value = "email">Email
<input id = "contact" type = "checkbox" name = "whatsapp" value = "whatsapp">Whatsapp
<input id = "contact" type = "checkbox" name = "in_app" value = "in_app">In-app chat
</fieldset>
<br><br>
<input type = "submit" value = "Submit">
</body>
First thing, make sure you close the following tag. That seems to be causing some problems.
Change it from this:
<label id="address">
To this:
<label id="address"></label>
I have a basic form, that I'm trying to get two inputs per line. Unless the 'province' select tag is floated right, it breaks the spacing. If it's 5th, like in the code I posted, there becomes a blank spot between Postal Code and Fax. The tab order even remains correct (phone -> fax -> email -> web).
Where if it's floated right (6th in this screenshot) everything spaces fine.
My form:
<form id="form" action="submit.php" method="post">
<fieldset>
<p>
<label for="first_name">* First Name:</label>
<input type="text" name="first_name" id="first_name" required />
</p>
<p>
<label for="last_name">* Last Name:</label>
<input type="text" name="last_name" id="last_name" required />
</p>
<p>
<label for="address">Company Address:</label>
<input type="text" name="address" id="address" />
</p>
<p>
<label for="city">City:</label>
<input type="text" name="city" id="city" />
</p>
<p>
<label for="province">Province:</label>
<select name="province" id="province">
<option value="">Select location</option>
<option value="AB">Alberta</option>
<option value="BC">British Columbia</option>
<option value="MB">Manitoba</option>
<option value="NB">New Brunswick</option>
<option value="NL">Newfoundland and Labrador</option>
<option value="NS">Nova Scotia</option>
<option value="NT">Northwest Territories</option>
<option value="NT">Nunavut</option>
<option value="ON">Ontario</option>
<option value="PE">Prince Edward Island</option>
<option value="QC">Quebec</option>
<option value="SK">Saskatchewan</option>
<option value="YT">Yukon</option>
<option value="US">(US State)</option>
</select>
</p>
<p>
<label for="postal_code">Postal Code:</label>
<input type="text" name="postal_code" id="postal_code" />
</p>
<p>
<label for="phone">* Phone:</label>
<input type="tel" name="phone" id="phone" required />
</p>
<p>
<label for="fax">Fax:</label>
<input type="tel" name="fax" id="fax" />
</p>
<p>
<label for="email">E-Mail Address:</label>
<input type="email" name="email" id="email" />
</p>
<p>
<label for="web_address">Website Address:</label>
<input type="text" name="web_address" id="web_address" />
</p>
</fieldset>
</form>
And my CSS:
fieldset p {
display: inline-block;
width: 49%;
}
fieldset p:nth-of-type(even){
float:right;
}
And if I remove the 'province' select tag everything spaces fine. With the province list, it always breaks the second 'float: right' after the select tag. Is there something wrong with my select tag? Or is it something with my CSS?
JSFiddles:
First screenshot: http://jsfiddle.net/sB2W7/
Second screenshot: http://jsfiddle.net/4CfQ5/
I would use display: inline-block instead of float
DEMO http://jsfiddle.net/LLJ6Z/2/
p {
display: inline-block;
width: 45%
}
label {
display: inline-block;
width: 130px;
display
}
input, select {
display: inline-block;
width: 100px;
}