I am trying to create an inline form where the label is on top of the input like in a bootstrap form. I have tried various options and although i have menaged to get the label on top of the input, the layout breaks after the first 2 inputs.
I have done a screenshot and would appreciate it someone could check my code and point out my error. many thanks
BTW:
The form-group i am using is not to be confused with the bootstrap
form-group.
.form-group {
display: inline-block;
margin-bottom: 0 !important;
margin-top: 10px !important;
width: 45%;
padding: 5px 5px;
}
.form-area {
background-color: #161616;
padding: 10px 40px 20px;
margin: 10px 0px 50px;
border: 1px solid #111;
}
.form-control {
background: -moz-linear-gradient(90deg, rgba(64, 64, 64, 1) 0%, rgba(33, 33, 33, 1) 100%) repeat scroll 0 0 padding-box !important;
border-radius: 5px;
box-shadow: 0 0 2px #4b4b4b inset, 0 1px 1px rgba(0, 0, 0, 0.3) !important;
color: #fff !important;
font-size: 0.875rem;
line-height: 1.43;
min-height: 2.8em !important;
padding: 0.5em 1.07em;
border: none;
color: #999 !important;
}
#editForm {
display: inline;
}
.labelStyle {
display: block;
color: black;
margin-left: 5px;
font-size: 14px;
}
.svcBorder {
border: 1px solid #2d2d2d;
border-radius: 5px;
padding: 15px;
margin-bottom: 5px;
margin-top: 30px;
}
input[type="text"] {
display: block;
width: 100%;
height: 24px;
border-radius: 5px;
margin-top: 5px;
padding: 4px 8px 0;
font-size: 14px;
color: dimgrey;
-webkit-box-sizing: border-box;
/* For legacy WebKit based browsers */
-moz-box-sizing: border-box;
/* For legacy (Firefox <29) Gecko based browsers */
box-sizing: border-box;
}
<form id="editForm" name="editForm" style="display: none;">
<div id="message">
<div class="text"></div>
</div>
<div class="form-group">
<label class="labelStyle" for="id">id</label>
<input id="id" name="id" readonly type="text" value="">
</div>
<div class="form-group">
<label class="labelStyle" for="service">Service</label>
<input id="service" name="service" type="text" value="">
</div>
<div class="form-group">
<label class="labelStyle" for="activity">Activity</label>
<input id="activity" name="activity" type="text" value="">
</div>
<div class="form-group">
<label class="labelStyle" for="dept">Department</label>
<input id="dept" name="dept" type="text" value="">
</div>
<div class="form-group">
<label class="labelStyle" for="company">Company</label>
<input id="company" name="company" type="text" value="">
</div>
<div class="form-group">
<label class="labelStyle" for="user">User</label>
<input id="user" name="user" type="text" value="">
</div>
<div class="form-group">
<label class="labelStyle" for="item">Item</label>
<input id="item" name="item" type="text" value="">
</div>
<div class="form-group">
<label class="labelStyle" for="date">Date</label>
<input id="date" name="date" type="text" value="">
</div>
</form>
According to your screenshot, this seems to affect the very first field in your form only - so the element preceding it,
<div id="message"><div class="text"></div></div>
likely has something to do with that ...
We didn’t see any styling for that in your code snippet, but if it has margins/paddings/borders or anything like that set, it might still influence the position of the following elements, even if it is currently “empty” (as in, no text content.)
Related
The code is as follows:
.form-wrapper {
border: 1px solid rgb(68, 240, 0);
background-image: radial-gradient(rgb(252, 252, 252), #ffffff);
border-radius: 20px;
width: 400px;
position: relative;
padding: 10px 40px;
margin: 10px auto;
}
.close-button {
position: absolute;
right: 0px;
left: auto;
border: 1px solid rgb(240, 0, 0);
width: 40px;
}
.form-header {
border: 1px solid rgb(232, 0, 240);
position: relative;
text-align: center;
}
.form-header h3 {
display: inline;
}
.form-outline {
border: 1px solid rgb(237, 250, 235);
border-radius: 20px;
padding: 5px 30px;
}
.form-field {
margin-top: 5px;
}
.form-field input {
outline: none;
width: 100%;
display: block;
padding: 5px;
font-size: 15px;
border: 2px solid rgb(179, 177, 177);
border-radius: 6px;
background-color: rgba(227, 247, 250, 0.918);
}
.form-field small {
display: block;
visibility: hidden;
}
<div class="form-wrapper">
<div class="close-button"><i class="far fa-times-circle "></i></div>
<div class="form-header">
<!-- <div style="border: 2px solid aqua;"></div> -->
<h3> Lets talk!</h3>
</div>
<form class="form-outline">
<div class="form-field">
<label class="field-title">Name </label><br>
<input type="text" id="" value="" placeholder="Enter your name."> <br>
<small class="error-message">Error message</small>
</div>
<div class="form-field">
<label class="field-title">Phone </label><br>
<input type="text" id="" value="" placeholder="Enter your phone number."> <br>
<small class="error-message">Error message</small>
</div>
<div class="form-field">
<label class="field-title">Organization </label><br>
<input type="text" id="" value="" placeholder="Enter your organization's name."><br>
<small class="error-message">Error message</small>
</div>
<div class="form-field">
<label class="field-title">Address </label><br>
<input type="text" id="" value="" placeholder="Enter your address."> <br>
<small class="error-message">Error message</small>
</div>
<div class="form-field">
<label class="field-title">Email </label><br>
<input type="text" id="" value="" placeholder="Enter your email."> <br>
<small class="error-message">Error message</small>
</div>
</form>
</div>
The result looks like this.
I want to move the "close button" to the right side sticking to the green border of form-wrapper div. The right property is not working. I don't know if it is a silly mistake or lack of knowledge. Any help or direction would be appreciated.
I tested the right property using another html file and it is working perfectly. But I could not move this close button to right.
try to add this to your close-button class. it worked for me.
.close-button {
direction: rtl;
}
Your code is fine and should work propely. Maybe your styles without right: 0px; is cached by browser. Try to open your project in new private / incognito tab. It prevents browser to read cached styled.
So I have these black boxes go round the input area on the form I am building. Is there a way I can remove this, I am also using bootstrap not sure if that is affecting it but if there is any ideas. Greatly appreciated!
.form-input-styling {
border-radius: 0 2em;
padding: 0 10px;
width: 50%;
border: none;
line-height: 2em;
margin-bottom: 20px;
background-color: #f25b43;
}
<div class="row">
<div class="col-12"><input class="form-input form-input-styling" type="text" id="fname" name="fname" required placeholder="Name"></div>
<div class="col-12"><input class="form-input form-input-styling" type="email" id="email" name="email" required placeholder="Email"></div>
<div class="col-12"><input class="form-input form-input-styling" type="tel" id="phone_num" name="phone_num" placeholder="Phone Number"></div>
<div class="col-12"><textarea id="text-area" name="textarea" rows="4" cols="50" placeholder="Enter Your Message Here"></textarea></div>
<div class="col-12"><input type="submit" value="Submit"></div>
</div>
Add outline: none; to your css for the input element.
.form-input-styling {
border-radius: 0 2em;
padding: 0 10px;
width: 50%;
border: none;
outline: none;
line-height: 2em;
margin-bottom: 20px;
background-color: #f25b43;
}
I come to you about an issue that I'm having with a contact form that I created using bootstrap see the jsfiddle below for a replica of my code...
My issue is the two buttons that I have for submit and clear are displaying on top of each other for some reason instead of inline next to each other...
I used CSS to format the form contents as table rows, columns and cells all contact labels are in one column and form fields in another (that's if I got my CSS coded properly) and I've put the form in a div with bootstrap class of col-md-6 which will only give it 50% width of the page...
Anyhow like I mentioned my issue is the two buttons are showing under the first column of the table under the labels which I guess is not giving it enough room and as a result the two buttons are stacked on top of each other my question is how would I go about showing the two buttons next to each other by using the full width of the form instead the width of the column??
Here is a link to my jsfiddle: https://jsfiddle.net/neenus/nofuvqod/3/
#jumbotron-form {
display: block;
opacity: 0.90;
}
form {
text-align: left;
display: table;
border-spacing: 0.25em;
}
.form-group {
display: table-row;
}
label {
display: table-cell;
vertical-align: top;
}
input {
display: inline;
}
textarea {
width: 100%;
}
<div class="jumbotron" id="jumbotron-form">
<div class="col-md-6">
<form action="SUBMIT">
<div class="form-group">
<label for="name">Name: </label>
<input type="text" name="name" id="name" placeholder="enter your name" autocomplete="off">
</div>
<div class="form-group">
<label for="tel">Telephone: </label>
<input type="tel" name="tel" pattern="Telephone" id="tel" placeholder="(999) 999-9999" autocomplete="off">
</div>
<div class="form-group">
<label for="email">e-Mail: </label>
<input type="email" name="email" id="email" placeholder="name#email.ca" autocomplete="off">
</div>
<div class="form-group">
<label for="usrmsg">Message: </label>
<textarea name="message" id="usrmsg" cols="50" rows="5" placeholder="enter your message here..."></textarea>
</div>
<div>
<input type="submit" value="Submit" id="submit">
<input type="reset" value="Clear">
</div>
</form>
</div>
</div>
Here is the HTML5 & Bootstrap markup for your code....
/***********************************************************************************************/
/* Input Field */
/***********************************************************************************************/
input[type="text"],
input[type="name"],
input[type="phone"],
input[type="email"],
textarea {
border: none;
padding: 8px;
border-radius: 3px;
width:100%;
color: #454545;
font-size: 16px;
font-style: normal;
background-color: #F5F5F5;
}
input[type="text"]:hover:focus,
input[type="name"]:hover:focus,
input[type="phone"]:hover:focus,
input[type="email"]:hover:focus,
textarea:hover:focus {
padding: 8px;
border-radius: 3px;
min-width: 280px;
font-style: normal;
background: #F5F5F5;
}
/***********************************************************************************************/
/* Button & Reset */
/***********************************************************************************************/
input[type="submit"],
input[type="reset"],
button {
font-size: 16px;
font-weight: 300;
border: none;
padding: 10px 30px;
color: #ffffff;
border-radius: 2px;
text-shadow: 1px 1px 1px rgba(0, 0, 0, .2);
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
/* border radius */
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
/* prevents bg color from leaking outside the border */
background-color: #2FB7D5;
/* layer fill content */
-moz-box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
/* inner shadow */
-webkit-box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
/* inner shadow */
box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
/* inner shadow */
}
input[type="submit"]:hover,
input[type="reset"]:hover,
button:hover {
font-size: 16px;
font-weight: 300;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
/* border radius */
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
/* prevents bg color from leaking outside the border */
background-color: #2FB7D5;
/* layer fill content */
-moz-box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
/* inner shadow */
-webkit-box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
/* inner shadow */
box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2);
/* inner shadow */
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<!-- ================================================
Contact Form Start
================================================= -->
<section class="contact-form">
<div class="container">
<div class="row">
<div class="col-lg-6 col-lg-offset-3">
<form action="" method="post" name="form" id="form">
<p>
<label for="name">Name</label>
<input type="text" name="" id="name" placeholder="Name" required>
</p>
<p>
<label for="email">Email</label>
<input type="email" name="email" id="email" placeholder="Email" required>
</p>
<p>
<label for="message">Message</label>
<textarea name="" id="message" cols="40" rows="5" placeholder="Write here..." required></textarea>
</p>
<input type="submit" value="Send">
<input type="reset" value="Write Again">
</form>
</div>
</div>
</div>
</section>
You can use flex-box for this , here i updated your code please check the snippet and fiddle
#jumbotron-form {
display: block;
background-size: cover;
opacity: 0.90;
}
form {
text-align: left;
display: table;
border-spacing: 0.25em;
}
.form-group {
display: table-row;
}
label {
display: table-cell;
vertical-align: top;
}
input {
display: inline;
}
textarea {
width: 100%;
}
.submit {
display: flex;
}
.submit input {
margin-right: 20px;
}
<div class="jumbotron" id="jumbotron-form">
<div class="col-md-6">
<form action="SUBMIT">
<div class="form-group">
<label for="name">Name: </label>
<input type="text" name="name" id="name" placeholder="enter your name" autocomplete="off">
</div>
<div class="form-group">
<label for="tel">Telephone: </label>
<input type="tel" name="tel" pattern="Telephone" id="tel" placeholder="(999) 999-9999" autocomplete="off">
</div>
<div class="form-group">
<label for="email">e-Mail: </label>
<input type="email" name="email" id="email" placeholder="email#domain.com" autocomplete="off">
</div>
<div class="form-group">
<label for="usrmsg">Message: </label>
<textarea name="message" id="usrmsg" cols="50" rows="5" placeholder="enter your message here..."></textarea>
</div>
<div class="submit">
<input type="submit" value="Submit" id="submit">
<input type="reset" value="Clear">
</div>
</form>
</div>
</div>
Problem is because you used display: table in <form>. I modified your markup and css by adding another <div> wrapper for all .form-group elements.
Checkout it out: https://jsfiddle.net/nofuvqod/5/
Snippet:
#jumbotron-form {
display: block;
background-size: cover;
opacity: 0.90;
}
form {
text-align: left;
border-spacing: 0.25em;
}
.form-table{
display: table;
}
.form-group {
display: table-row;
}
label {
display: table-cell;
vertical-align: top;
}
input {
display: inline;
}
textarea {
width: 100%;
}
HTML
<div class="jumbotron" id="jumbotron-form">
<div class="col-md-6">
<form action="SUBMIT">
<div class="form-table">
<div class="form-group">
<label for="name">Name: </label>
<input type="text" name="name" id="name" placeholder="enter your name" autocomplete="off">
</div>
<div class="form-group">
<label for="tel">Telephone: </label>
<input type="tel" name="tel" pattern="Telephone" id="tel" placeholder="(999) 999-9999" autocomplete="off">
</div>
<div class="form-group">
<label for="email">e-Mail: </label>
<input type="email" name="email" id="email" placeholder="email#domain.com" autocomplete="off">
</div>
<div class="form-group">
<label for="usrmsg">Message: </label>
<textarea name="message" id="usrmsg" cols="50" rows="5" placeholder="enter your message here..."></textarea>
</div>
</div>
<div>
<input type="submit" value="Submit" id="submit">
<input type="reset" value="Clear">
</div>
</form>
</div>
</div>
Use the button container with form-group class.
<div class="form-group">
<input type="submit" value="Submit" id="submit">
<input type="reset" value="Clear">
</div>
I am creating a registration form and am wondering how can I move the whole form to the center of the page? right now its all on the left side of the container, I want it to look a bit something like this: https://id2.s.nfl.com/fans/register?returnTo=http%3A%2F%2Fweeklypickem.fantasy.nfl.com%2F
#Regcontainer {
width: 1200px;
margin: 70px auto;
border: 1px solid;
background-color: aliceblue;
top: 0;
}
.Regcontainer h1 {
font-size: 40px;
font-family: 'Helvetica Neue', sans-serif;
color: black;
line-height: 1;
padding-left: 35px;
padding-top: 35px;
color: black;
}
input {
display: inline-block;
margin: 10px;
}
input[type=text] {
padding: 10px;
border: 2px solid #212;
border-radius: 2px;
box-shadow: #212121;
}
input[type=password] {
padding: 10px;
border: 2px solid #212;
border-radius: 2px;
padding: 5px 10px 5px 10px;
}
input[type=submit] {
background-color: #ff0000;
border: 1px solid #212121;
border-radius: 5px;
color: aliceblue;
font-weight: bold;
}
#back_form {
justify-content: center;
}
<div id="Registercontainer">
<div class="RegForm">
<h1> </h1>
<div id="back_glob">
<div id="back_form">
<form method="POST">
<label>FIRST NAME</label>
<input type="text" name="FName" />
<label>LAST NAME</label>
<input type="text" name="SNAME" />
<br/>
<label>EMAIL ADDRESS</label> <input id="email" name="email" type="text" />
<BR/>
<label>CREATE YOUR USERNAME</label> <input name="uname" type="text" /> <br/>
<label>CREATE PASSWORD</label> <input name="pass" type="password" />
<br/>
<input type="submit" name="valid" value="REGISTER" />
</form>
</div>
</div>
</div>
Here is the solution I came up with... but what does it do?
#Registercontainer needs to be on the center of the page. Meaning, your fixed with of 1200px is not going to work too well. I took the approach of reducing the size of your from container to give a better look and feel like this:
#Registercontainer {
max-width: 600px;
min-width: 320px;
width: 100%;
/* ... your other properties here ... */
}
Another note, your <label> needs the for attribute as specified in this article.
Let me know if you have any questions, FYI there are many ways to make this work for you.
#Registercontainer {
max-width: 600px;
min-width: 320px;
width: 100%;
margin: 70px auto;
border: 1px solid;
background-color: aliceblue;
top: 0;
padding: 15px;
}
.Regcontainer h1 {
font-size: 40px;
font-family: 'Helvetica Neue', sans-serif;
color: black;
line-height: 1;
padding-left: 35px;
padding-top: 35px;
color: black;
}
input {
display: inline-block;
margin: 10px;
}
input[type=text] {
padding: 10px;
border: 2px solid #212;
border-radius: 2px;
box-shadow: #212121;
}
input[type=password] {
padding: 10px;
border: 2px solid #212;
border-radius: 2px;
padding: 5px 10px 5px 10px;
}
input[type=submit] {
background-color: #ff0000;
border: 1px solid #212121;
border-radius: 5px;
color: aliceblue;
font-weight: bold;
}
#back_form {
justify-content: center;
}
<div id="Registercontainer">
<div class="RegForm">
<h1> Register With NackStack</h1>
<div id="back_glob">
<div id="back_form">
<form method="POST">
<label for="fname">FIRST NAME</label>
<input type="text" name="FName" id="fname" />
<br/>
<label for="sname">LAST NAME</label>
<input type="text" name="SNAME" id="sname" />
<br/>
<label for="email">EMAIL ADDRESS</label>
<input id="email" name="email" type="text" />
<br/>
<label for="uname">CREATE YOUR USERNAME</label>
<input name="uname" type="text" id="uname" />
<br/>
<label for="password">CREATE PASSWORD</label>
<input name="pass" type="password" id="password"/>
<br/>
<input type="submit" name="valid" value="REGISTER" />
</form>
</div>
</div>
</div>
Add margin:auto and a fixed width to the parent <div>. Example:
<div id="Registercontainer" style="margin-left:auto;margin-right:auto;width:250px">
Fiddle:
https://jsfiddle.net/mwatz122/g9ay26x3/
#Registercontainer {
text-align: center;
}
Please try this. It might help.
Put your form within a <div> like this:
<div align="center">
<!-- insert code here -->
</div>
Then in the CSS, add
form {
text-align: left;
}
Question:
1. Why is the "required" function not working in my contact form?
2. Why can I not make use of the full width of the input-field. See img.
I can only write on the left half of the input field.
HTML:
<div id="content">
<div class="contact">
<fieldset class="name group">
<label for="name" class="name">Name</label>
<input id="name" name="name" required pattern="[A-Za-z-0-9]+\s[A-Za-z]+" title="firstname lastname"/>
</fieldset>
<fieldset class="email group">
<label for="email" class="email">Email</label>
<input type="email" id="email" name="email" required title="Submit a valid Email">
</fieldset>
<fieldset class="phone group">
<label for="phone" class="phone">Telephone</label>
<input type="tel" id="phone" name="phone" pattern="(\+?\d[- .]*){7,17}" required title="Submit an international, national or local phone number"/>
</fieldset>
<fieldset class="message group">
<label class="message">Message</label>
<input type="text" id="message" required/>
</fieldset>
<fieldset class="send group">
<input type="submit" value="Send" class="sendButton">
</fieldset>
</div>
</div>
CSS:
#content
{
max-width: 50.694%;
position: absolute;
bottom: 0;
background: none repeat scroll 0 0 rgba(0, 0, 0, .55);
border-radius: 13px;
width: 730px;
margin: 0 0 6.6% 25.9167%;
box-shadow: 0 0 0 2px #000000, 2px 2px 30px 1px rgba(199, 255, 100, 0.73);
}
.contact{
width: 100%;
margin: 10px;
}
fieldset{
border: 0;
margin: 0;
width: 100%;
padding: 1%;
}
.name, .email, .message{
padding-right: 29px;
}
label{
color: #d8d9de;
font-family:'apple_chancerychancery';
font-size: 1.2em;
padding-left: 10px;
}
input{
margin-right: 70px;
padding: 6px;
text-align: left;
border-radius: 10px;
background: none repeat scroll 0 0 rgba(255, 240, 260, 0.5);
}
#name, #email, #phone, #message{
padding-right: 50%;
float: right;
color: #253c93;
text-decoration: none;
border: 1px dotted #29FF00;
font-family: 'Calibri', Arial, sans-serif;
font-size: 1em;
width: 23%;
}
div#inner-editor{
padding: 30px;
}
#message{
padding-top: 10%;
}
.sendButton{
background: rgba(0, 0, 0, 0);
color: #d8d9de;
font-size: 1.2em;
font-family: 'apple_chancerychancery';
padding: 0.8% 4%;
border: none;
margin-left: 42%;
box-shadow: inset 2px 2px 9px rgba(199, 255, 100, 0.73), inset -2px -2px 9px rgba(199,
255, 100, 0.73);
}
::-webkit-input-placeholder { /* WebKit browsers */
color: #d8d9de;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: #d8d9de;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #d8d9de;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
color: #d8d9de;
}
You are missing your form tag. It works for me once I add your form tag in:
<div id="content">
<div class="contact">
<form>
<fieldset class="name group">
<label for="name" class="name">Name</label>
<input id="name" name="name" required pattern="[A-Za-z-0-9]+\s[A-Za-z]+" title="firstname lastname"/>
</fieldset>
<fieldset class="email group">
<label for="email" class="email">Email</label>
<input type="email" id="email" name="email" required title="Submit a valid Email">
</fieldset>
<fieldset class="phone group">
<label for="phone" class="phone">Telephone</label>
<input type="tel" id="phone" name="phone" pattern="(\+?\d[- .]*){7,17}" required title="Submit an international, national or local phone number"/>
</fieldset>
<fieldset class="message group">
<label class="message">Message</label>
<input type="text" id="message" required/>
</fieldset>
<fieldset class="send group">
<input type="submit" value="Send" class="sendButton">
</fieldset>
</form>
</div>
</div>
http://jsfiddle.net/GEs34/
Here is the fiddle where your second issue has been resolved.
Just removed the padding-right from the name, email, phone and message id input fields and increased their width percentage.