Contact Form not displayed as Block - html

I'm trying to make a contact form in Reactjs for my website, but I'm unable to make the form itself be displayed as a block. Right now, the form is being displayed as if it were on the same line, despite the display being set to block.
I'm not sure why I'm having this problem
Relevant Code
ContactPage.js
import React from 'react';
// CSS import statements
import '../css/Base.css';
import '../css/ContactPage.css';
// Component import statements
function Contact() {
return(
<div className='container'>
<div className='contact-form'>
Fields marked with an * are required.
<label for="name">Name *</label>
<input type="text" name="name" />
<label for="email">Email *</label>
<input type="text" name="email" />
<label for="subject">Subject *</label>
<input type="text" name="subject" />
<label for="message">Message *</label>
<input type="text" name="message" />
<button>Submit</button>
</div>
</div>
)
}
export default Contact;
ContactPage.css
.contact-form {
display: block;
padding: 0px 10px;
}

Try this.
ContactPage.js
import React from 'react';
// CSS import statements
import '../css/Base.css';
import '../css/ContactPage.css';
// Component import statements
function Contact() {
return(
<div className='container'>
<div id='contact-form'>
Fields marked with an * are required.
<div className='row'>
<div className="label">
<label for="name">Name *</label>
</div>
<div class="form-input">
<input type="text" name="name" className="form-control"/>
</div>
</div>
<div className='row'>
<div className="label">
<label for="email">Email *</label>
</div>
<div className="form-input">
<input type="text" name="email" className="form-control"/>
</div>
</div>
<div className='row'>
<div className="label">
<label for="subject">Subject *</label>
</div>
<div className="form-input">
<input type="text" name="subject" className="form-control"/>
</div>
</div>
<div className='row'>
<div className="label">
<label for="message">Message *</label>
</div>
<div className="form-input">
<input type="text" name="message" className="form-control"/>
</div>
</div>
<div className='form-button'>
<button>Submit</button>
</div>
</div>
</div>
)
}
export default Contact;
ContactPage.css
#contact-form {
display: block;
padding: 0px 10px;
}
.row:after{
content: "";
display: table;
clear: both;
}
.form-button{
margin-top:10px;
}
.label {
float: left;
width: 15%;
margin-top: 6px;
}
.form-input{
float: left;
width:50%;
margin-top: 6px;
}
Preview --> https://codesandbox.io/s/vigilant-lumiere-ue3k1?file=/src/App.js

Re-edit your contact form structure to this:
HTML
<div className='contact-form'>
Fields marked with an * are required.
<div class="form-group">
<label for="name">Name *</label>
<input type="text" name="name" />
</div>
<div class="form-group">
<label for="email">Email *</label>
<input type="text" name="email" />
</div>
<div class="form-group">
<label for="subject">Subject *</label>
<input type="text" name="subject" />
</div>
<div class="form-group">
<label for="message">Message *</label>
<input type="text" name="message" />
</div>
<button>Submit</button>
</div>
Wrap it inside a div called form-group and in your css
ContactPage.css
.contact-form {
display: block;
padding: 0px 10px;
}
.contact-form .form-group {
width:100%;
display:block;
position: relative;
}
.contact-form .button {
display:block;
margin:0 auto;
}

Related

Prevent input data from showing in url - Flask

I am gathering customer data from a web app - however once data is input the data displays in the URL search bar and I am just wondering about how to prevent that from happening?
here is my current code:
<form>
<div class="row">
<div class="col-75">
<div class="container">
<form action="/action_page.php", method="POST">
<div class="row">
<div class="col-50">
<h3>Billing Address</h3>
<label for="fname"><i class="fa fa-user"></i> Full Name</label>
<input type="text" id="fname" name="firstname" placeholder="John M. Doe">
<label for="email"><i class="fa fa-envelope"></i> Email</label>
<input type="text" id="email" name="email" placeholder="john#example.com">
<label for="adr"><i class="fa fa-address-card-o"></i> Address</label>
<input type="text" id="adr" name="address" placeholder="1234 Example Street, Richmond">
<label for="city"><i class="fa fa-institution"></i> Suburb</label>
<input type="text" id="city" name="city" placeholder="Melbourne">
<div class="row">
<div class="col-50">
<label for="state">State</label>
<input type="text" id="state" name="state" placeholder="Victoria">
</div>
<div class="col-50">
<label for="postcode">Post Code</label>
<input type="text" id="postcode" name="postcode" placeholder="3934">
</div>
</div>
</div>
<div class="col-50">
<h3>Payment</h3>
<label for="fname">Accepted Cards</label>
<div class="icon-container">
<i class="fa fa-cc-visa" style="color:navy;">Visa</i>
<i class="fa fa-cc-amex" style="color:blue;">Amex</i>
<i class="fa fa-cc-mastercard" style="color:red;">Mastercard</i>
</div>
<label for="cname">Name on Card</label>
<input type="text" id="cname" name="cardname" placeholder="John More Doe">
<label for="ccnum">Credit card number</label>
<input type="text" id="ccnum" name="cardnumber" placeholder="1111-2222-3333-4444">
<label for="expmonth">Exp Month</label>
<input type="text" id="expmonth" name="expmonth" placeholder="September">
<div class="row">
<div class="col-50">
<label for="expyear">Exp Year</label>
<input type="text" id="expyear" name="expyear" placeholder="2018">
</div>
<div class="col-50">
<label for="cvv">CVV</label>
<input type="text" id="cvv" name="cvv" placeholder="352">
</div>
</div>
</div>
</div>
<label>
<input type="checkbox" checked="checked" name="sameadr"> Shipping address same as billing
</label>
<input type="submit" value="Continue to checkout" class="btn">
</form>
</div>
</div>
.row {
display: -ms-flexbox; /* IE10 */
display: flex;
-ms-flex-wrap: wrap; /* IE10 */
flex-wrap: wrap;
margin: 0 -16px;
}
.col-25 {
-ms-flex: 25%; /* IE10 */
flex: 25%;
}
.col-50 {
-ms-flex: 50%; /* IE10 */
flex: 50%;
}
.col-75 {
-ms-flex: 75%; /* IE10 */
flex: 75%;
}
.col-25,
.col-50,
.col-75 {
padding: 0 16px;
}
.container {
background-color: #f2f2f2;
padding: 5px 20px 15px 20px;
border: 1px solid lightgrey;
border-radius: 3px;
}
input[type=text] {
width: 100%;
margin-bottom: 20px;
padding: 12px;
border: 1px solid #ccc;
border-radius: 3px;
}
label {
margin-bottom: 10px;
display: block;
}
.icon-container {
margin-bottom: 20px;
padding: 7px 0;
font-size: 24px;
}
.btn {
background-color: #04AA6D;
color: white;
padding: 12px;
margin: 10px 0;
border: none;
width: 100%;
border-radius: 3px;
cursor: pointer;
font-size: 17px;
}
.btn:hover {
background-color: #45a049;
}
span.price {
float: right;
color: grey;
}
/* Responsive layout - when the screen is less than 800px wide, make the two columns stack on top of each other instead of next to each other (and change the direction - make the "cart" column go on top) */
#media (max-width: 800px) {
.row {
flex-direction: column-reverse;
}
.col-25 {
margin-bottom: 20px;
}
}
Any help would be really appreciated :)
You have an unnecessary <form> tag on the first line of your HTML and you are missing a closing </div> tag at the end. Changing this seems to resolve the issue:
<div class="row">
<div class="col-75">
<div class="container">
<form action="/action_page.php" , method="POST">
<div class="row">
<div class="col-50">
<h3>Billing Address</h3>
<label for="fname"><i class="fa fa-user"></i> Full Name</label>
<input type="text" id="fname" name="firstname" placeholder="John M. Doe">
<label for="email"><i class="fa fa-envelope"></i> Email</label>
<input type="text" id="email" name="email" placeholder="john#example.com">
<label for="adr"><i class="fa fa-address-card-o"></i> Address</label>
<input type="text" id="adr" name="address" placeholder="1234 Example Street, Richmond">
<label for="city"><i class="fa fa-institution"></i> Suburb</label>
<input type="text" id="city" name="city" placeholder="Melbourne">
<div class="row">
<div class="col-50">
<label for="state">State</label>
<input type="text" id="state" name="state" placeholder="Victoria">
</div>
<div class="col-50">
<label for="postcode">Post Code</label>
<input type="text" id="postcode" name="postcode" placeholder="3934">
</div>
</div>
</div>
<div class="col-50">
<h3>Payment</h3>
<label for="fname">Accepted Cards</label>
<div class="icon-container">
<i class="fa fa-cc-visa" style="color:navy;">Visa</i>
<i class="fa fa-cc-amex" style="color:blue;">Amex</i>
<i class="fa fa-cc-mastercard" style="color:red;">Mastercard</i>
</div>
<label for="cname">Name on Card</label>
<input type="text" id="cname" name="cardname" placeholder="John More Doe">
<label for="ccnum">Credit card number</label>
<input type="text" id="ccnum" name="cardnumber" placeholder="1111-2222-3333-4444">
<label for="expmonth">Exp Month</label>
<input type="text" id="expmonth" name="expmonth" placeholder="September">
<div class="row">
<div class="col-50">
<label for="expyear">Exp Year</label>
<input type="text" id="expyear" name="expyear" placeholder="2018">
</div>
<div class="col-50">
<label for="cvv">CVV</label>
<input type="text" id="cvv" name="cvv" placeholder="352">
</div>
</div>
</div>
</div>
<label>
<input type="checkbox" checked="checked" name="sameadr"> Shipping address same as billing
</label>
<input type="submit" value="Continue to checkout" class="btn">
</form>
</div>
</div>
</div>
(Note: my editor may have formatted your code differently to the original question)

Bootstrap form - scroll does not appear when screen is resized

I'm working on a project with a Bootstrap form. Very simply, I would like the form to have a scroll bar when the window is resized. I tried adding the overflow-auto class to my div, but that doesn't work for it. So when I resize my window, no scroll appears. Here's my code.
.form-container {
border-radius: 25px;
border: 1px solid black;
padding: 15px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.register-container { max-width: 500px; }
.title-header {
font-size: 25px;
font-weight: bold;
}
<div class="overflow-auto container form-container register-container">
<h1 class="title-header">REGISTER</h1>
<form id="register" method="post" action="register">
<?php writeMessageBoxIfMessage($message); ?>
<div class="form-group row">
<div class="col-sm-6">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">FIRST NAME</label> <br>
<input id="firstname" name="firstname" maxlength="80" required>
</div>
<div class="col-sm-6">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">LAST NAME</label> <br>
<input id="lastname" name="lastname" maxlength="80" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">EMAIL</label> <br>
<input type="email" id="email" name="email" maxlength="255" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">PASSWORD</label> <br>
<input type="password" id="password" name="password" maxlength="80" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">CONFIRM PASSWORD</label> <br>
<input type="password" id="confirm-password" name="confirm-password" maxlength="80" required>
</div>
<div class="col-sm-6">
Already have an account? <br> Click here</span> to login.
</div>
<div class="col-sm-6">
<input id="register" type="submit" name="submit"
value="REGISTER" />
</div>
</div>
</form>
</div>
Can anyone provide some suggestions so I can get this to scroll?
Can’t replicate this at the moment but try using
position: absolute;
and give a container
position: relative;
Rather than using the ‘fixed’ position.
Let me know if this doesn’t work.
I hope you want internal scroll if the form is more in height.
Use the following CSS,
Try it.
#register {
max-height: 200px;
overflow: scroll;
}
Please add media
#media (max-height: 420px) {
#register {
height: 150px;
overflow-x: hidden;
overflow-y: scroll;
}
}
for better solution and check your device height should be (max-height: yourDeviceHeight) in media
.form-container {
border-radius: 25px;
border: 1px solid black;
padding: 15px;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.register-container { max-width: 500px; }
.title-header {
font-size: 25px;
font-weight: bold;
}
#media (max-height: 420px) {
#register {
height: 150px;
overflow-x: hidden;
overflow-y: scroll;
}
}
<div class="overflow-auto container form-container register-container">
<h1 class="title-header">REGISTER</h1>
<form id="register" method="post" action="register">
<?php writeMessageBoxIfMessage($message); ?>
<div class="form-group row">
<div class="col-sm-6">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">FIRST NAME</label> <br>
<input id="firstname" name="firstname" maxlength="80" required>
</div>
<div class="col-sm-6">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">LAST NAME</label> <br>
<input id="lastname" name="lastname" maxlength="80" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">EMAIL</label> <br>
<input type="email" id="email" name="email" maxlength="255" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">PASSWORD</label> <br>
<input type="password" id="password" name="password" maxlength="80" required>
</div>
<div class="col-sm-12">
<label for="colFormLabelSm" class="col-sm-12 col-form-label col-form-label-sm">CONFIRM PASSWORD</label> <br>
<input type="password" id="confirm-password" name="confirm-password" maxlength="80" required>
</div>
<div class="col-sm-6">
Already have an account? <br> Click here</span> to login.
</div>
<div class="col-sm-6">
<input id="register" type="submit" name="submit"
value="REGISTER" />
</div>
</div>
</form>
</div>

justify-content space-between not aligning elements left and right

Alright, so I am trying to use Flexbox to align my form on the left hand side of the screen and my image on the right hand of the screen using justify-content: space-between but when I put that on my .container it doesn't work. Here is what I have so far:
<form>
<div class="heading">
<h1 class="callout">Send Us A Message!</h1>
</div>
<div class="container">
<div class="form-group">
<label>First Name</label>
<input type="text" class="form-control" name="firstname">
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" class="form-control" name="lastname">
</div>
<div class="form-group">
<label>Phone Number</label>
<input type="text" class="form-control" name="phonenumber">
</div>
<div class="form-group">
<label>Email Address</label>
<input type="email" class="form-control" name="email">
</div>
<div class="form-group">
<label>Message</label>
<textarea name="message" cols="30" rows="10">
</textarea>
<button class="btn-1">Send</button>
</div>
<div class="image">
<img src="img/city.jpg" alt="">
</div>
</div>
</form>
My style:
.container {
display: flex;
justify-content: space-between;
flex-direction: column;
}
img {
width: 20%;
}
Put the two sections in their own containers, then it can work.
.container {
display: flex;
justify-content: space-between;
}
section:first-child {
background-color: orange;
}
section:last-child {
background-color: lightgreen;
}
.image {
border: 2px dashed black;
height: 100px;
width: 100px;
}
<form>
<div class="heading">
<h1 class="callout">Send Us A Message!</h1>
</div>
<div class="container">
<section><!-- container one -->
<div class="form-group">
<label>First Name</label>
<input type="text" class="form-control" name="firstname">
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" class="form-control" name="lastname">
</div>
<div class="form-group">
<label>Phone Number</label>
<input type="text" class="form-control" name="phonenumber">
</div>
<div class="form-group">
<label>Email Address</label>
<input type="email" class="form-control" name="email">
</div>
<div class="form-group">
<label>Message</label>
<textarea name="message" cols="30" rows="10">
</textarea>
<button class="btn-1">Send</button>
</div>
</section>
<section><!-- container two -->
<div class="image"> image
<img src="img/city.jpg" alt="">
</div>
</section>
</div>
</form>

How to combine grouped inputs with aligned forms?

From Pure CSS I want to combine aligned forms:
<link href="https://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/forms-min.css" rel="stylesheet" />
<form class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-control-group">
<label for="name">Username</label>
<input id="name" type="text" placeholder="Username">
</div>
<div class="pure-control-group">
<label for="password">Password</label>
<input id="password" type="password" placeholder="Password">
</div>
<div class="pure-control-group">
<label for="email">Email</label>
<input id="email" type="email" placeholder="Email">
</div>
</fieldset>
</form>
with grouped inputs:
<link href="https://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/forms-min.css" rel="stylesheet" />
<form class="pure-form">
<fieldset class="pure-group">
<input type="text" placeholder="Username">
<input type="text" placeholder="Password">
<input type="email" placeholder="Email">
</fieldset>
</form>
so that the inputs are stacked while still allowing horizontally aligned labels to be placed to the left. How can I achieve this effect?
I came to a solution by applying the grouped input styling to a modified aligned form layout:
.pure-form-aligned .pure-group .pure-control-group {
margin: 0;
}
.pure-form.pure-form-aligned .pure-group .pure-control-group input {
display: inline-block;
position: relative;
margin: 0 0 -1px;
border-radius: 0;
top: -1px;
}
.pure-form-aligned .pure-group .pure-control-group:first-child input {
top: 1px;
border-radius: 4px 4px 0 0;
margin: 0;
}
.pure-form-aligned .pure-group .pure-control-group:last-child input {
top: -2px;
border-radius: 0 0 4px 4px;
margin: 0;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/forms-min.css" rel="stylesheet" />
<form class="pure-form pure-form-aligned">
<fieldset class="pure-group">
<div class="pure-control-group">
<label for="name">Username</label>
<input id="name" type="text" placeholder="Username">
</div>
<div class="pure-control-group">
<label for="password">Password</label>
<input id="password" type="password" placeholder="Password">
</div>
<div class="pure-control-group">
<label for="email">Email</label>
<input id="email" type="email" placeholder="Email">
</div>
</fieldset>
</form>
You can wrap the <label>s in a div and place that div on the left side of the <fieldset>. Like this :-
div.labels{
display : inline-block;
height : 100px;
}
div.labels div{
display : flex;
align-items : center;
justify-content : right;
height : 33.33%;
}
fieldset.pure-group{
height : 100px;
display : inline-block;
}
fieldset.pure-group input{
height : 33.33%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/forms-min.css" rel="stylesheet" />
<form class="pure-form">
<div class="labels">
<div>
<label>Name</label>
</div>
<div>
<label>Password</label>
</div>
<div>
<label>Email</label>
</div>
</div>
<fieldset class="pure-group">
<input type="text" id="name" placeholder="Username">
<input type="text" placeholder="Password">
<input type="email" placeholder="Email">
</fieldset>
</form>

Making forms that have double columns

So i have this form that i quickly made and i got it so that i can make double columns now.
link: http://codepen.io/zomdar/pen/WbXBaq
<head>
</head>
<body>
<fieldset>
<form>
<div class="half">
<label for="name">Name</label>
<input type="text" id="name" name="name">
</div>
<div class="half">
<label for="email">Email</label>
<input type="text" id="email" name="email">
</div>
<div class="half">
<label for="zip">Zip / Postal code</label>
<input type="text" id="zip" name="zip">
</div>
<div class="half">
<label for="country">Country</label>
<select id="country" name="country"><option></option></select>
</div>
<div class="full">
<label for="message">Message</label>
<textarea id="message" name="message"></textarea>
</div>
<div class="half">
<input type="checkbox" id="copy" name="copy">
<label for="copy">Send me a copy</label>
</div>
<div class="half right">
<input type="submit" value="send">
</div>
</form>
</fieldset>
</body>
</html>
CSS:
fieldset { width: 900px; }
input[type=text], select, textarea { width: 98%; }
.half { float: left; width: 48%; padding: 1%; }
.full { clear: both; width: 98%; padding: 1%; }
.right { text-align: right; }
but the problem is that when i put the div tag half and put it in the html....i have to put 2 "half" fields for it to go to the next line. I cant just put 1 half class and another half class right below the half class. Any ideas on how i can do that? add another class maybe?
add a class .clear { clear: both; } like this:
fieldset { width: 500px; padding: 1%; }
input[type=text], select, textarea { width: 98%; }
.half { float: left; width: 48%; padding: 1%; }
.clear { clear: both; }
.full { clear: both; width: 98%; padding: 1%; }
.right { text-align: right; }
<head>
</head>
<body>
<fieldset>
<legend>Contact form</legend>
<form>
<div class="half">
<label for="name">Name</label>
<input type="text" id="name" name="name">
</div>
<div class="clear"></div><!-- added div class clear -->
<div class="half">
<label for="email">Email</label>
<input type="text" id="email" name="email">
</div>
<div class="half">
<label for="zip">Zip / Postal code</label>
<input type="text" id="zip" name="zip">
</div>
<div class="half">
<label for="country">Country</label>
<select id="country" name="country"><option></option></select>
</div>
<div class="full">
<label for="message">Message</label>
<textarea id="message" name="message"></textarea>
</div>
<div class="half">
<input type="checkbox" id="copy" name="copy">
<label for="copy">Send me a copy</label>
</div>
<div class="half right">
<input type="submit" value="send">
</div>
</form>
</fieldset>
</body>
</html>