Centering input and textarea not matching - html

Trying to center two inputs side by side, and a textarea just below it
form ul {
list-style: none;
text-align: center;
}
form ul li {
display: inline-block;
margin-left: auto;
margin-right: auto;
}
#nameform,
#emailform,
#messageform {
font-family: 'Open Sans', sans-serif;
font-weight: 300;
font-color: #cfcfcf;
font-size: 15px;
border: 1px solid #ccc;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
padding: 4px 7px;
outline: 0;
-webkit-appearance: none
}
#nameform,
#emailform {
margin-left: auto;
margin-right: auto;
height: 35;
}
#messageform {
display: block;
margin-right: auto;
margin-left: auto;
}
<div id="contactform">
<form>
<ul>
<li>
<input type="text" name="name" placeholder="name" id="nameform" size="35"></input>
<li>
<li>
<input type="text" name="email" placeholder="email" id="emailform" size="35">
</innput>
<li>
</ul>
<textarea type="text" name="message" placeholder="Message" id="messageform" rows="4" cols="80"></textarea>
</form>
</div>
And for some reason it is displayed on google and IE as this:
How can i make it so the textarea is completely centered underneath the two inputs?

You had some syntax errors, and I made small changes https://jsfiddle.net/DIRTY_SMITH/fedz7nx7/2/
form ul{
list-style: none;
text-align:center;
}
form ul li {
display: inline-block;
margin-left: auto;
margin-right: auto;
}
#nameform, #emailform, #messageform {
font-family: 'Open Sans', sans-serif;
font-weight: 300;
font-color: #cfcfcf;
font-size: 15px;
border: 1px solid #ccc;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
padding: 4px 7px;
outline: 0;
-webkit-appearance: none
}
#nameform, #emailform {
margin-left: auto;
margin-right: auto;
height: 35;
}
#messageform {
display: block;
margin-right: auto;
margin-left: auto;
}

Many syntax errors, many unnecessary settings (and some that may be necessary for your styling purposes, but are not necessary to solve the problem).
The following is how I would approach this issue.
form ul {
list-style: none; /* Remove bullets */
margin: 0; /* Remove list spacing */
font-size: 0; /* Remove white-space between inline-block tags */
padding: 5px; /* A little bit of spacing */
}
form ul li {
display: inline-block; /* Allow the list items to be on the same line */
width: 50%; /* list items should be half-width */
box-sizing: border-box; /* Declared sizes should include padding */
padding: 5px; /* A little bit of spacing */
}
form ul li:nth-child(3) {
width: 100%; /* The third list item should be full-width */
}
form ul li input,
#messageform {
width: 100%; /* the inputs and textarea should be full-width */
box-sizing: border-box; /* Declared sizes should include padding */
}
/* Environment */ body { margin: 0; }
<div id="contactform">
<form>
<ul>
<li>
<input type="text" name="name" placeholder="name" id="nameform">
</li>
<li>
<input type="text" name="email" placeholder="email" id="emailform">
</li>
<li>
<textarea type="text" name="message" placeholder="Message" id="messageform" rows="4"></textarea>
</li>
</ul>
</form>
</div>

Related

Header photo moving around

I recently received some help to fix an issue with my footer being in the middle of the page (much much appreciated!) but it looks like I have another issue - the photo in my header (supposed to be centered and fixed) is now more to the left and moves when I scroll the page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset= "utf-8">
<Title>Contact</Title>
<link rel="stylesheet" href="contact3.css">
</head>
<body>
<header>
<nav>
<ul>
<!-- list item one -->
<li>
Home
</li>
<!-- list item two -->
<li>
About
</li>
<!-- list item three -->
<li>
Services
</li>
<!-- list item four -->
<li>
Contact
</li>
</ul>
</nav>
<img src="CG1.svg" alt-text="Collision Guru Logo" width=250px height=80px class="center">
</header>
<h1> Contact Us</h1><div class="form-container">
<div class="form-container">
<img src="yellow car headlight collision.jpg" width=450px height=400px class="carimg">
<form action="C:\Users\elizabeth.sweeney\Downloads\form_data.php" method="post">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"> <br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
<label for="email">Email:</label><br>
<input type="email" id="email" name="email"><br>
<label for="phone">Phone:</label><br>
<input type="phone" id="phone" name="phone">
<br>
<input type="checkbox" id="option1" name="option1" value="Paint">
<label for="option1"> Paint Job</label><br>
<input type="checkbox" id="option2" name="option2" value="Body">
<label for="option2"> Body Work</label><br>
<input type="checkbox" id="option3" name="option3" value="Clean">
<label for="option3"> Cleaning</label><br>
<div class="submitbutton">
<input type="submit" value="Submit"></div>
</form>
</div>
<footer>
<nav>
<div class="contactinfo">
440-555-6893 • mike.tarescavage#gmail.com
</div>
<div class="sociallinks">
<img src= "facebook-icon.png" width=30px height=30px> <img src= "IG-icon-2.png" width=30px height=30px>
</div>
</nav>
</footer>
</body>
</html>
CSS:
body {
margin: 0;
background: #ffffff;
font-family: century gothic;
font-size: 18px;
text-align: center;
padding-bottom: 40px;
}
header {
background: #000000;
height: 125px;
color: #ffffff;
}
a{
color: #ffffff;
text-decoration: none;
}
ul{
margin: 0;
padding: 0px;
/*this option by default dispose the elements in a row (flex-direction: row)*/
display: flex;
}
li{
list-style-type: none;
/*when I specify 2 values to margin, the first one is for the top and bottom side, the second for the left and right side*/
margin: 0 1vw;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
width: 50%;
top: 20px;
position: fixed;
}
h1 {
text-align: center;
font-family: century gothic;
font-size: 60px;
font-weight: bold;
color: #000000;
}
.form-container {
overflow: hidden;
}
form
{
float: right;
margin-right: 75px;
text-align: left;
display: inline-block;
}
input[type=text], select {
width: 100%;
text-align:left;
padding: 12px 20px;
margin: 8px 0;
margin-left: 30px;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-right: 50px;
}
input[type=email], select {
width: 100%;
text-align:left;
padding: 12px 20px;
margin: 8px 0;
margin-left: 30px;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-right: 50px;
}
input[type=phone], select {
width: 100%;
text-align:left;
padding: 12px 20px;
margin: 8px 0;
margin-left: 30px;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
margin-right: 50px;
}
input[type=checkbox] {
text-align: left;
display: in-line block;
margin-left: 30px;
}
.submitbutton {
text-align: center;
padding-left: 80px;
display: block;
}
input[type=submit] {
width: 75%;
margin-left: 30px;
background-color: #000000;
color: white;
padding: 12px 20px;
padding-left: 30px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
display: in-line block;
}
.carimg {
float: left;
margin-left: 50px;
padding-bottom: 90px;
}
footer {
background: #000000;
height: 125px;
color: #ffffff;
}
.footerlinks {
float: left;
word-spacing: 30px;
text-align: left;
padding-top: 50px;
margin-left: 20px;
}
.contactinfo {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
text-align: center;
padding-top: 50px;
}
.sociallinks {
float: right;
margin-right: 40px;
word-spacing: 20px;
}
This happened after adding the form-container class - not sure if that has anything to do with it, or perhaps another step needs to be taken with the photo? Or is it's completely unrelated.
Please let me know your thoughts.
Thanks! :)
If you want your logo to stay fixed in the top center on scroll, then update the css to be:
.center {
display: block;
margin-bottom: 20px;
width: 50%;
top: 20px;
left: 50%;
transform: translateX(-50%);
position: fixed;
}
But if you want it to only be centered on your header, then you just need to remove the "center" class form the logo.
You have display: fixed; applied to your .center class which is causing your img element in the header to move with the scrollbar. Removing the class="center" attribute from the img element solves the scrolling issue but now your image is positioned slightly to the right of where it was.

How do I remove the padding inside a div that has a propery of display and a value of inline-block

How do I remove the padding from inside of a div with the display set to "inline-block".
Below is the html and css.
.showExpCusWrap {
background-color: #A8D3FF;
display: inline-block;
border: 1px solid #004F9D;
padding: 0px 10px;
font-family: Tahoma;
}
.showExpCusWrap label {
font-size: 0.9em;
margin: 0px;
padding: 0px;
}
.showExpCusWrap input[type="date"] {
margin: 0px;
padding: 0px;
}
<div class="showExpCusWrap">
<label for="showExpFrom">From</label>
<input type="date" name="showExpFrom" id="showExpFrom">
<label for="showExpTo">To</label>
<input type="date" name="showExpTo" id="showExpTo">
<input type="button" name="showExpCus" id="showExpCus" value="Show" class="exp-button-small">
</div>
This is how it looks. Notice the top and bottom padding inside.
I have checked the broswer default styling. It does not set any padding. So, how to remove those? I want all the elements inside the div to appear without any spacing from top or bottom.
While editing your question, I realized that there's no problem.
Here's a snippet of all the code that you sent.
.showExpCusWrap {
background-color: #A8D3FF;
display: inline-block;
border: 1px solid #004F9D;
padding: 0px 10px;
font-family: Tahoma;
}
.showExpCusWrap label {
font-size: 0.9em;
margin: 0px;
padding: 0px;
}
.showExpCusWrap input[type="date"]{
margin: 0px;
padding: 0px;
}
<div class="showExpCusWrap">
<label for="showExpFrom">From</label>
<input type="date" name="showExpFrom" id="showExpFrom">
<label for="showExpTo">To</label>
<input type="date" name="showExpTo" id="showExpTo">
<input type="button" name="showExpCus" id="showExpCus" value="Show" class="exp-button-small">
</div>
You may use line-height increase or decrease it , this is to be check through different browsers of course .. (form elements are also part of the browser not only html tags).
.showExpCusWrap {
background-color: #A8D3FF;
display: inline-block;
border: 1px solid #004F9D;
padding: 10px;
font-family: Tahoma;
}
.showExpCusWrap label {
font-size: 0.9em;
margin: 0px;
padding: 0px;
}
.showExpCusWrap input[type="date"] {
margin: 0px;
padding: 0px;
}
/* increase all
label, input:not([type="button"]) {
line-height:1.4em;
}
*/
label,
input {
vertical-align: middle;
box-sizing:border-box;
}
/* or decrease the one
[type="button"] {
line-height: 1em;
}
<div class="showExpCusWrap">
<label for="showExpFrom">From</label>
<input type="date" name="showExpFrom" id="showExpFrom">
<label for="showExpTo">To</label>
<input type="date" name="showExpTo" id="showExpTo">
<input type="button" name="showExpCus" id="showExpCus" value="Show" class="exp-button-small">
</div>
I have come to this solution. May be this is the solution you are looking for. To your .showExpCusWrap class I add these lines of CSS and it's work for me.
/* add the following code*/
line-height:1;
font-size:0.9em;
As you declare a relative font-size with em value; So to adjust the height of the inline block I took same amount of height with the help of line-height:1;. Here is full code for you.
.showExpCusWrap {
background-color: #A8D3FF;
display: inline-block;
border: 1px solid #004F9D;
padding: 0px 10px;
font-family: Tahoma;
/* add the following code*/
line-height: 1;
font-size: 0.9em;
}
.showExpCusWrap label {
font-size: 0.9em;
margin: 0px;
padding: 0px;
}
.showExpCusWrap input[type="date"] {
margin: 0px;
padding: 0px;
}
* {
box-sizing: border-box;
}
<div class="showExpCusWrap">
<label for="showExpFrom">From</label>
<input type="date" name="showExpFrom" id="showExpFrom">
<label for="showExpTo">To</label>
<input type="date" name="showExpTo" id="showExpTo">
<input type="button" name="showExpCus" id="showExpCus" value="Show" class="exp-button-small">
</div>

The outer box does not fit the input field

I am trying to make a login form. The outer box of the form is big and does not fit with the input field. How can I minimize the size of the outer box? I am trying it for the first time. So, I have no idea.
templatemo_style.css: The css part
form {
border: 3px solid #f1f1f1;
}
/* Full-width inputs */
input[type=text], input[type=password] {
width: 100%;
padding: 10px 5px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
align-content: center;
}
/* Set a style for all buttons */
button {
background-color: #4CAF50;
color: white;
margin: 8px 0;
border: none;
cursor: pointer;
width: 80px;
height: 25px;
padding: 3px 22px 0 0;
font-size: 12px;
font-weight: bold;
text-align: center;
text-decoration: none;
}
/* Add a hover effect for buttons */
button:hover {
opacity: 0.8;
}
/* Extra style for the cancel button (red) */
.cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}
/* Center the avatar image inside this container */
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
/* Avatar image */
img.avatar {
width: 40%;
border-radius: 50%;
}
/* Add padding to containers */
.container {
margin: 25px auto;
position: relative;
width: 900px;
}
/* The "Forgot password" text */
span.psw {
float: right;
padding-top: 16px;
}
/* Change styles for span and cancel button on extra small screens */
#media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
.cancelbtn {
width: 100%;
}
}
index.jsp: Html code for the form
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Student Profile</title>
<link href="css/templatemo_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="index.jsp">
<div class="container">
Username:
<input type="text" placeholder="Enter Username" name="uname" required>
Password:
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
</div>
<div class="container" style="background-color:#f1f1f1">
<button type="button" class="cancelbtn">Cancel</button>
<span class="psw">Forgot password?</span>
</div>
</form>
</body>
</html>
One way to achieve this is
Change the Html Like this
<div class="container">
<form action="index.jsp">Username:
<input type="text" placeholder="Enter Username" name="uname" required>
Password:
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
<div style="background-color:#f1f1f1">
<button type="button" class="cancelbtn">Cancel</button>
<span class="psw">Forgot password?</span>
</div>
</form>
</div>
And your css Like this
form {
border: 3px solid #f1f1f1;padding: 10px;
}
/* Full-width inputs */
input[type=text], input[type=password] {
width: 100%;
padding: 10px 5px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
align-content: center;
}
/* Set a style for all buttons */
button {
background-color: #4CAF50;
color: white;
margin: 8px 0;
border: none;
cursor: pointer;
width: 80px;
height: 25px;
padding: 3px 22px 0 0;
font-size: 12px;
font-weight: bold;
text-align: center;
text-decoration: none;
}
/* Add a hover effect for buttons */
button:hover {
opacity: 0.8;
}
/* Extra style for the cancel button (red) */
.cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}
/* Center the avatar image inside this container */
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
/* Avatar image */
img.avatar {
width: 40%;
border-radius: 50%;
}
/* Add padding to containers */
.container {
margin: 25px auto;
position: relative;
width: 900px;
}
enter code here
/* The "Forgot password" text */
span.psw {
float: right;
padding-top: 16px;
}
/* Change styles for span and cancel button on extra small screens */
#media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
.cancelbtn {
width: 100%;
}
}
the result will be
hope this will do
If you put your <form> tag inside the <div class="container"> tag, the outline only goes around the form.
<body>
<div class="container">
<form action="index.jsp">
Username: ...
You might want to add some padding to make it look nice, too ;)
Also, please don't have a stroke to be able to ask your question. The "It looks like your post is mostly code; please add some more details." warning is there for a reason.

Display inline or float without breaking - without using media queries

When I try to add float left or display inline, things break. Currently, I have a max-width of 1000px for the form. What I was hoping is somehow, the first, and last name will automatically float side by side if it is wide enough. So perhaps a min-width for inputs First and Last name?
Important note: I wrote this to test out writing CSS DRY code. You notice if you change the font size, the whole project changes size, So this is important to me. Also, I do not want to use media queries.
I am aware that I may need to change my approach, and I am open to that as well. Not so much looking for an exact code answer.
form {
text-align: center;
}
form ul, form li, form input, form label {
box-sizing: border-box;
margin: 0; padding: 0;
}
form ul {
font-size: 100%;
border: 3px solid #000;
border-radius: .3em;
max-width: 1000px;
margin: 50px auto;
list-style: none;
overflow: hidden;
}
form li {
position: relative;
border-bottom: inherit;
border-bottom: 3px solid;
}
form label {
position: absolute;
border-bottom: 1px dotted;
border-bottom-color: inherit;
width: 100%;
padding: .3em .3em;
padding-bottom: .1em;;
top: 0; left: 0;
font-size: .6em;
text-transform: uppercase;
}
form input, form input:focus {
text-transform: capitalize;
text-align: inherit;
background: transparent;
border: none;
width: 100%;
font-size: 2em;
padding: .7em .1em;
padding-bottom: .2em;;
}
form input:focus {
background-color: rgba(255, 255, 0, .2);
}
form input[type="submit"] {
text-transform: uppercase;
padding-bottom: 1.8em;
font-size: .6em;
height: 1.5em;
background-color: #ddd;
}
<form action="">
<ul>
<li>
<input id="first-name" type="text" autofocus>
<label for="first-name">First Name</label>
</li>
<li>
<input id="last-name" type="text">
<label for="last-name">Last Name</label>
</li>
<li>
<input id="username" type="text">
<label for="username">Username</label>
</li>
<li>
<input type="submit" name="submit">
</li>
</ul>
</form>
Flexbox is the most modern solution to this problem. However, remember to add the necessary prefixes for some browsers. If IE9 support is necessary, see the float solution below:
HTML
<form action="">
<ul>
<li class="split">
<input id="first-name" type="text" autofocus>
<label for="first-name">First Name</label>
</li>
<li class="split">
<input id="last-name" type="text">
<label for="last-name">Last Name</label>
</li>
<li class="fill">
<input id="username" type="text">
<label for="username">Username</label>
</li>
<input type="submit" name="submit">
</ul>
</form>
CSS
form {
text-align: center;
}
form ul, form li, form input, form label {
box-sizing: border-box;
margin: 0; padding: 0;
}
form ul {
font-size: 100%;
border: 3px solid #000;
border-radius: .3em;
max-width: 1000px;
margin: 50px auto;
list-style: none;
overflow: hidden;
}
form li {
position: relative;
border-bottom: inherit;
border-bottom: 3px solid;
}
form label {
position: absolute;
border-bottom: 1px dotted;
border-bottom-color: inherit;
width: 100%;
padding: .3em .3em;
padding-bottom: .1em;;
top: 0; left: 0;
font-size: .6em;
text-transform: uppercase;
}
form input, form input:focus {
text-transform: capitalize;
text-align: inherit;
background: transparent;
border: none;
width: 100%;
font-size: 2em;
padding: .7em .1em;
padding-bottom: .2em;;
}
form input:focus {
background-color: rgba(255, 255, 0, .2);
}
form input[type="submit"] {
text-transform: uppercase;
padding-bottom: 1.8em;
font-size: .6em;
height: 1.5em;
background-color: #ddd;
}
#media only screen and (min-width: 768px) {
li {
clear: both;
}
li.split {
width: 50%;
float: left;
clear: none;
}
}
https://jsfiddle.net/qefo9eLr/
.fl-name {
display: flex;
flex-direction: row;
}
you can try to use bootstrap grid system
this way u can have the inputs into columns
bootstrap grid system
look at this fiddle:
gri system sample
<div class='row'>
<div class="col-xs-2">Hi</div>
<div class="col-xs-2">Hi</div>
in your case col-xs-6 will give you 2 columns fullwidth
Not exactly sure if this is what you're going for, but it seems to fit your criteria.
form {
text-align: center;
}
form ul,
form li,
form input,
form label {
box-sizing: border-box;
margin: 0;
padding: 0;
}
form ul {
font-size: 100%;
border: 3px solid #000;
border-radius: .3em;
max-width: 1000px;
margin: 50px auto;
list-style: none;
overflow: hidden;
}
form li {
position: relative;
border-bottom: inherit;
border-bottom: 3px solid;
}
form label {
position: absolute;
border-bottom: 1px dotted;
border-bottom-color: inherit;
width: 100%;
padding: .3em .3em;
padding-bottom: .1em;
;
top: 0;
left: 0;
font-size: .6em;
text-transform: uppercase;
}
form input,
form input:focus {
text-transform: capitalize;
}
form #fl-name {
display: inline-block;
}
form .floatMe {
float: left;
}
form .clearMe {
clear: right;
}
<form action="">
<ul>
<div class="fl-name">
<li class="floatMe">
<input id="first-name" type="text" autofocus>
<label for="first-name">First Name</label>
</li>
<li class="floatMe clearMe">
<input id="last-name" type="text">
<label for="last-name">Last Name</label>
</li>
</div>
<li>
<input id="username" type="text">
<label for="username">Username</label>
</li>
<input type="submit" name="submit">
</ul>
</form>
Here is another alternative using our old faithful floats: https://jsfiddle.net/mvpu6s5o/3/
The main difference is basically here:
form li {
width: 33.33%;
float: left;
}
form li:nth-child(3) {
float: right;
}
form li:last-child {
width: 100%;
clear: both;
}
I used a width with percentage to keep it fluid, so it'll adjust to different screen sizes. The li:nth-child(3) float the last input to the right, so we can get rid of a small gap at the end due to the 33.33% width. form li:last-child is used to clear both floats to the last input (since this too is an li).
I just change the semantic and apply flexbox. This is the result:
*, *:before, *:after {
box-sizing: inherit;
margin: 0;
padding: 0;
}
body {
align-items: center;
/background-color: #EB6361;
display: flex;
height: 100vh;
justify-content: center;
}
form {
box-shadow: 0 0 0 8px rgba(204,204,204,.85);
border-radius: 5px;
width: 500px;
}
form header {
background-color: #1ABC9C;
}
form header p {
color: #FFF;
font-family: 'ubuntu';
font-size: 15px;
padding: 15px 10px;
text-align: center;
}
form .body {
background-color: #EEE;
padding: 15px 20px;
}
form .body .block {
border: 2px solid #333;
border-radius: 4px;
overflow: hidden;
}
form .body .block:not(first-of-type) {
margin-top: 10px;
}
form .body .block:first-of-type > .group {
width: 98%;
}
form .body .block:first-of-type {
display: flex;
}
form .body .block .group {
display: flex;
flex-flow: column-reverse nowrap;
overflow: hidden;
}
form .body .block:first-of-type .group:first-of-type {
border-right: 2px solid #333;
}
form input {
background-color: transparent;
border: none;
color: #555;
font-size: 22pt;
padding: 6px 10px;
text-align: center;
}
form input:focus, form input:focus + label {
background-color: #F7F8E0;
}
form label {
border-bottom: 1px dotted #bbb;
color: #555;
font-family: 'ubuntu';
font-size: 11px;
padding: 2px;
text-align: center;
text-transform: uppercase;
}
form footer {
overflow: hidden;
}
form footer button {
background-color: #F39C12;
color: #FFF;
cursor: pointer;
width: 100%;
border: none;
padding: 4px;
}
<form action="">
<header>
<p>Submit Query Form</p>
</header>
<section class="body">
<div class="block">
<div class="group">
<input type="text" />
<label for="">First Name</label>
</div>
<div class="group">
<input type="text" />
<label for="">Last Name</label>
</div>
</div>
<div class="block">
<div class="group">
<input type="text" />
<label for="">Username</label>
</div>
</div>
</section>
<footer>
<button>Submit query</button>
</footer>
</form>
A very simple solution is with Flexbox.
Set the parent element to display type 'flex'.
Also set up flex wrap: wrap // This way the children will wrap if needed.
The children become flex objects. Since I want them to be even, I set them both to flex grow: 1
Set the children to flex-basis as 300px. // This is almost like a minimum width. This triggers the wrap.
body {
padding: 50px;
}
.main {
background-color: #e9e9e9;
display: flex;
flex-wrap: wrap;
}
.main input {
background-color: #e9e9e9;
}
.one {
flex-grow: 1;
flex-basis: 300px
}
.two {
flex-grow: 1;
flex-basis: 300px;
}
<head>
<link rel="stylesheet" href="inline.css">
</head>
<body>
<form class="main">
<input type="text" class="one">
<input type="text" class="two">
</form>
</body>

Center two lis inside ul horizontally

I have two lis inside a ul. And I'm not able to make the lis center.
I can center the li by giving fixed width to it. Can it be done without giving fixed width?
.PhNumber_email_list {
display: inline-block;
clear: both;
padding: 10px 0px;
width: 100%;
margin: 0 auto;
max-width: 700px;
border: 2px solid black;
}
.PhNumber_email_list li {
list-style: none;
float: left;
margin: 5px 20px;
position: relative;
}
.PhNumber_email_list li input {
border: 2px solid #196edf;
width: 100%;
padding: 15px 5px;
color: #3f3f3f;
text-align: center;
font-weight: 700;
}
<ul class="PhNumber_email_list">
<li>
<input type="text" placeholder="Email">
<p class="hint">Your email is kept private and secure</p>
</li>
<li>
<input type="text" class="PhNumber_mask" placeholder="Phone Number (Optional)">
<p class="hint">Get exclusive support</p>
</li>
</ul>
Heres the fiddle
demo - http://jsfiddle.net/99stwpnp/3/
use box-sizing:border-box for input so that the padding is calculated from inside
and instead of float:left use display:inline-block so that you center it without giving width
.PhNumber_email_list {
display: inline-block;
clear: both;
text-align: center;
padding: 10px 0px;
width: 100%;
margin: 0 auto;
max-width: 700px;
border: 2px solid black;
}
.PhNumber_email_list li {
list-style: none;
display: inline-block;
margin: 5px 20px;
position: relative;
}
.PhNumber_email_list li input {
border: 2px solid #196edf;
width: 100%;
box-sizing: border-box;
padding: 15px 5px;
color: #3f3f3f;
text-align: center;
font-weight: 700;
}
<ul class="PhNumber_email_list">
<li>
<input type="text" placeholder="Email">
<p class="hint">Your email is kept private and secure</p>
</li>
<li>
<input type="text" class="PhNumber_mask" placeholder="Phone Number (Optional)">
<p class="hint">Get exclusive support</p>
</li>
</ul>
If using a percentage for the width of the <li> is ok I think you can. In the following example I've added box-sizing: border-box to the li and the li input to include the padding and the border size in the width. I've added a width: 50% to the li and changed the margin into a padding.
.PhNumber_email_list {
display: inline-block;
padding: 10px 0px;
width: 100%;
margin: 0 auto;
max-width: 700px;
border: 2px solid black;
}
.PhNumber_email_list li {
box-sizing: border-box;
list-style: none;
float: left;
padding: 5px 20px;
width: 50%;
}
.PhNumber_email_list li input {
box-sizing: border-box;
border: 2px solid #196edf;
width: 100%;
padding: 15px 5px;
color: #3f3f3f;
text-align: center;
font-weight: 700;
}
<ul class="PhNumber_email_list">
<li>
<input type="text" placeholder="Email">
<p class="hint">Your email is kept private and secure</p>
</li>
<li>
<input type="text" class="PhNumber_mask" placeholder="Phone Number (Optional)">
<p class="hint">Get exclusive support</p>
</li>
</ul>