Input and button not aligned horizontally - html

I'm making an email form where people can submit their emails and be part of an email list, in order to do this I have made an input and a button that go side by side. The issue that I am getting is that even though the button and inputs are the exact same height, and should be aligned horizontally perfectly it instead has a pixel difference with the button being a pixel higher than the input. How can I fix this?
#form {
display flex;
align-items: center;
justify-content: center;
flex-direction: row;
}
.email-form {
padding: 60px;
margin-top: 85px;
color: #fff;
background: #000;
text-align: center;
}
.form input {
width: 300px;
height: 30px;
margin: 0;
display: inline;
outline: 0 none;
}
.form button {
height: 30px;
width: 90px;
margin: 0;
background: #707070;
color: #fff;
font-weight: 700;
text-transform: uppercase;
text-align: center;
border: none;
cursor: pointer;
display: inline;
outline: 0 none;
}
<div class="form">
<form action="" id="email">
<input type="email" placeholder="Email" /><button type="submit" class="submit"><p>Sign up</p></button>
</form>
</div>

If you change
<p>Sign up</p>
To
<div>Sign up</div>
Or just
Sign up
It should work.
There's a bunch of margin settings on the <p> element that are overflowing and messing up your alignment.

Just remove p tag around the Sign up text.
<button type="submit" class="submit">Sign up</button>
#form {
display flex;
align-items: center;
justify-content: center;
flex-direction: row;
}
.email-form {
padding: 60px;
margin-top: 85px;
color: #fff;
background: #000;
text-align: center;
}
.form input {
width: 300px;
height: 30px;
margin: 0;
display: inline;
outline: 0 none;
}
.form button {
height: 30px;
width: 90px;
margin: 0;
background: #707070;
color: #fff;
font-weight: 700;
text-transform: uppercase;
text-align: center;
border: none;
cursor: pointer;
display: inline;
outline: 0 none;
}
<div class="form">
<form action="" id="email">
<input type="email" placeholder="Email" />
<button type="submit" class="submit">Sign up</button>
</form>
</div>

Related

How can I adjust this Flexbox layout based on multiple criteria?

Current Layout
-------------------
- Banner Row:Group
- Column 1: Label Column 2: Input or Select Column 3: Button or Link
- EndGroup
- Banner Row:Group
- Column 1: Label Column 2: Input or Select Column 3: Button or Link
- EndGroup
- Banner Row:Group
- Column 1: Label Column 2: Input or Select Column 3: Button or Link
- EndGroup
I would like Col1 (label) to be right justified, equal fixed widths
I would like Col2 (input or select) to be same size, fixed width
I would like Col3 (Button or Link) to be left justified
I would like decreasing window width to wrap col component onto next line like at the same time for each column
body {
display: flex;
align-items: center;
justify-content: center;
}
#box {
flex-direction: column;
justify-content: center;
background-color: wheat;
display: flex;
border: 2px solid black;
border-radius: 15px;
border-color: black;
padding: 20px 40px;
margin: 10px 50px;
box-shadow: 5px 10px 18px #888888;
}
#banner {
display: flex;
flex-direction: column;
align-items: center;
background-color: #0099cc;
border-radius: 500px;
padding: 10px 50px 0 50px;
margin: 0 auto 10px auto;
}
#banner-text {
font-size: 14px;
text-align: center;
color: white;
margin-bottom: 15px;
}
.right {
font-size: 10px;
text-align: right;
}
#box input[type="tel"], input[type="email"], select {
font-size: 100%;
margin: 0 10px;
width: 200px;
}
a:link {
font-size: 12px;
font-weight: bold;
text-decoration: none;
align-self: center;
}
a:hover {
text-decoration: underline;
color: blue;
}
.button {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
width: 150px;
border: 2px solid #0099cc;
background-color: #0099cc;
color: #ffffff;
border-radius: 15px;
text-decoration: none;
outline: none;
}
.button:hover {
border: 2px solid white;
color: #ffffff;
padding: 5px 10px;
}
.button:disabled {
border: 1px solid #999999;
background-color: #cccccc;
color: #666666;
}
textarea {
font-size: 18px;
height: 250px;
width: 100%;
}
label {
font-weight: bold;
}
.group {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
<div id="box">
<div id="banner">
<img
src="https://www.google.com/logos/doodles/2020/thank-you-public-health-workers-and-to-researchers-in-the-scientific-community-6753651837108753-law.gif"
alt="Banner"
width="300"
height="92"
/>
<h3>Header Text</h3>
</div>
<div>
<label for="input">Provider:</label>
<select id="selected">
<option value="opt1">Option #1</option>
</select>
https://www.google.com
</div>
<div>
<label for="input">Patient Email:</label>
<input
type="email"
id="email"
name="email"
placeholder="user#domain.com"
/>
<input type="button" class="button" value="Send Email" />
</div>
<div>
<label for="input">Patient Mobile Phone:</label>
<input
type="tel"
id="sms"
name="sms"
placeholder="(123) 456-7890"
/>
<input type="button" class="button" value="Send SMS Text" />
</div>
</div>
JSFiddle
Here's a possibility for you. Based on what you were saying you wanted, it seemed to me that css grid was the better option.
So, I added css grid with grid-template-columns: max-content max-content 1fr; as the columns and it'll add new rows as you create them.
I made the wrapping divs (.grid>div) use display: contents although it isn't fully supported on all major browsers yet, the way to get around using that would be to just remove the wrapping divs as grid will take care of the rest anyway.
body {
display: flex;
align-items: center;
justify-content: center;
}
#box {
flex-direction: column;
justify-content: center;
background-color: wheat;
display: flex;
border: 2px solid black;
border-radius: 15px;
border-color: black;
padding: 20px 40px;
margin: 10px 50px;
box-shadow: 5px 10px 18px #888888;
}
#banner {
display: flex;
flex-direction: column;
align-items: center;
background-color: #0099cc;
border-radius: 500px;
padding: 10px 50px 0 50px;
margin: 0 auto 10px auto;
}
#banner-text {
font-size: 14px;
text-align: center;
color: white;
margin-bottom: 15px;
}
.right {
font-size: 10px;
text-align: right;
}
#box input[type="tel"],
input[type="email"],
select {
font-size: 100%;
margin: 0 10px;
/*width: 200px;*/
}
a:link {
font-size: 12px;
font-weight: bold;
text-decoration: none;
align-self: center;
}
a:hover {
text-decoration: underline;
color: blue;
}
.button {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
width: 150px;
border: 2px solid #0099cc;
background-color: #0099cc;
color: #ffffff;
border-radius: 15px;
text-decoration: none;
outline: none;
}
.button:hover {
border: 2px solid white;
color: #ffffff;
padding: 5px 10px;
}
.button:disabled {
border: 1px solid #999999;
background-color: #cccccc;
color: #666666;
}
textarea {
font-size: 18px;
height: 250px;
width: 100%;
}
label {
font-weight: bold;
}
.group {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
.grid {
display: grid;
grid-template-columns: max-content max-content 1fr;
}
.grid>div {
display: contents;
}
.grid>div>:first-child {
justify-self: flex-end;
}
#media only screen and (max-width: 600px) {
.grid {
grid-template-columns: 1fr;
}
.grid>div>:first-child {
justify-self: flex-start;
}
}
<div id="box">
<div id="banner">
<img src="https://www.google.com/logos/doodles/2020/thank-you-public-health-workers-and-to-researchers-in-the-scientific-community-6753651837108753-law.gif" alt="Banner" width="300" height="92" />
<h3>Header Text</h3>
</div>
<div class="grid">
<div>
<label for="input">Provider:</label>
<select id="selected">
<option value="opt1">Option #1</option>
</select>
https://www.google.com
</div>
<div>
<label for="input">Patient Email:</label>
<input type="email" id="email" name="email" placeholder="user#domain.com" />
<input type="button" class="button" value="Send Email" />
</div>
<div>
<label for="input">Patient Mobile Phone:</label>
<input type="tel" id="sms" name="sms" placeholder="(123) 456-7890" />
<input type="button" class="button" value="Send SMS Text" />
</div>
</div>
</div>

How to make the label go up after clicking with css?

I want to make a form when on clicked the label would go up 15px and you can write the text, but I can't figure out how to do it with my current code. I think the problem is how I select the label and input.
I tried these ways:
.form-row-field-input:focus ~ label,
.form-row-field-input:valid ~ label {
top: -12px;
left: 0;
font-size: 12px;
color: #003333;
font-weight: bold;}
input[type=text]:focus~label {
display:block;
color: black;
top: -20px;
font-size: 14px;}
<div class="form-inputs">
<form action="" method="POST">
<div class="form-row">
<span class="form-row-number">01</span>
<label for="POST-name" class="form-row-field">First name</label>
<input type="text" class="form-row-field-input">
</div>
<div class="form-row">
<span class="form-row-number">02</span>
<label for="POST-lastname" class="form-row-field">Last name</label>
<input type="text" class="form-row-field-input">
</div>
<div class="form-row">
<span class="form-row-number">03</span>
<label for="POST-email" class="form-row-field">Email</label>
<input type="text" class="form-row-field-input">
</div>
<input class="form-btn" type="submit" value="Get it">
</form>
</div><!--end-->
/** CSS **/
.form-inputs {
padding: 40px;
flex: 60%;
display: flex;
flex-direction: column;
align-content: center;
justify-content: center;
position: relative;
}
.form-btn {
margin: 20px 0px;
background-color: #f6fe00;
color: black;
padding: 10px 40px;
font-weight: 700;
border: none;
cursor: pointer;
}
.form-row {
border-bottom: 1px solid grey;
padding: 10px 0px;
position: relative;
}
.form-row-number {
color: #8f63ff;
padding-right: 10px;
}
.form-row-field {
color: #9b91f5;
position: absolute;
pointer-events: none;
transition: 0.5s;
top: 10px;
margin-left: 1em;
}
.form-row-field-input {
background-color: inherit;
border: none;
display: block;
position: absolute;
top: 10px;
transition: 0.5s;
margin-left: 1.5em;
}
I expect that when clicked on input, the label would go up with a transition
The general sibling selector in CSS that you're using can only target elements that come AFTER, so since the label comes before the input in your HTML, it's not actually applying the CSS.
You can get the intended effect simply be moving the label element after the input. Google's Material UI also takes this approach in order to keep it primarily CSS to achieve the intended visual effect.
Here it is with the label elements moved to after the input and slightly tweaked CSS:
<body>
<div class="form-inputs">
<form action="" method="POST">
<div class="form-row">
<span class="form-row-number">01</span>
<input type="text" class="form-row-field-input">
<label for="POST-name" class="form-row-field">First name</label>
</div>
<div class="form-row">
<span class="form-row-number">02</span>
<input type="text" class="form-row-field-input">
<label for="POST-lastname" class="form-row-field">Last name</label>
</div>
<div class="form-row">
<span class="form-row-number">03</span>
<input type="text" class="form-row-field-input">
<label for="POST-email" class="form-row-field">Email</label>
</div>
<input class="form-btn" type="submit" value="Get it">
</form>
</div>
<!--end-->
</body>
.form-inputs {
padding: 40px;
flex: 60%;
display: flex;
flex-direction: column;
align-content: center;
justify-content: center;
position: relative;
}
.form-btn {
margin: 20px 0px;
background-color: #f6fe00;
color: black;
padding: 10px 40px;
font-weight: 700;
border: none;
cursor: pointer;
}
.form-row {
border-bottom: 1px solid grey;
padding: 10px 0px;
position: relative;
}
.form-row-number {
color: #8f63ff;
padding-right: 10px;
}
.form-row-field {
color: #9b91f5;
position: absolute;
pointer-events: none;
transition: 0.5s;
top: 10px;
margin-left: 1em;
}
.form-row-field-input {
background-color: inherit;
border: none;
display: block;
position: absolute;
top: 10px;
transition: 0.5s;
margin-left: 1.5em;
}
.form-row-field-input:focus~label {
top: -5px;
font-size: 12px;
color: #003333;
font-weight: bold;
}
https://jsfiddle.net/7urgeL60/

HTML+CSS: How do I put this 2 buttons at the same level vertically

I want to align those two buttons (Login and Registrar) at the same level but as they are different forms "Registrar" button is being placed on the "next line".
Here is the issue, visually:
Here is the code:
HTML
<section class="header_form_login">
<form action="index2.html" method="GET">
<label for="user">Usuario:<br></label>
<input type="text" id="user" name="user_input">
<label for="pass"><br>Contraseña:<br></label>
<input type="text" id="pass" name="pass">
<input type="submit" id="login" value="Login">
</form>
<form action="registro.html" method="GET">
<input type="submit" id="register" value="Registrar">
</form>
</section>
CSS:
header > section.header_form_login{
font-weight: 500;
align-items: right;
padding: 5px;
margin: auto;
margin-right: 20px;
}
header > section.header_form_login > form > input#user{
width: 200px;
height: 24px;
border: 1px solid lightgray;
}
header > section.header_form_login > form > input#pass{
width: 200px;
height: 24px;
border: 1px solid lightgray;
}
/* BUTTONS */
header > section.header_form_login > form > input#login{
border: none;
background-color: #CAB99F;
color: black;
font-weight: 500;
font-family: 'Roboto';
font-size: 15px;
text-decoration: none;
padding: 10px 20px;
cursor: pointer;
display: block;
margin-top: 10px;
}
header > section.header_form_login > form > input#register{
border: none;
background-color: #CAB99F;
color: black;
font-weight: 500;
font-family: 'Roboto';
font-size: 15px;
text-decoration: none;
padding: 10px 30px;
cursor: pointer;
display: flex;
float: right;
margin-top: 10px;
}
Thanks a lot!!!
PD: Feel free to give me recommendations, I'm kinda new to html and css coding.
I need help with html and css, specifically, with buttons being placed at the same level vertically but from different forms
Update: Refactored CSS to share styles.
I would restructure your HTML and fix your CSS to get things working properly. Also, when using ids, they are meant to be unique, so there's no need for a long lookup query such as:
header > section.header_form_login > form > input#login { … }
Just use
#login { … }
To make the "buttons" align, I made the register input a link. This is pretty standard. Then I added some CSS to align these elements on the same line.
.form-buttons {
display: flex;
flex-wrap: nowrap;
}
Here is how I could restructure your markup and styles.
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.header_form_login {
font-weight: 500;
padding: 5px;
margin: auto;
width: 250px;
max-width: 100%;
}
#user,
#pass {
width: 100%;
padding: 5px;
border: 1px solid lightgray;
}
/* BUTTONS */
#login,
#register {
border: none;
background-color: #CAB99F;
color: black;
font-weight: 500;
font-family: 'Roboto';
font-size: 15px;
text-decoration: none;
padding: 10px 20px;
cursor: pointer;
text-align: center;
flex: 1;
}
#login {
margin-right: 2.5px;
}
#register {
margin-left: 2.5px;
}
.form-buttons {
padding-top: 10px;
display: flex;
flex-wrap: nowrap;
}
<section class="header_form_login">
<form action="index2.html" method="GET">
<label for="user">Usuario:<br></label>
<input type="text" id="user" name="user_input">
<label for="pass">Contraseña:</label>
<input type="text" id="pass" name="pass">
<div class="form-buttons">
<input type="submit" id="login" value="Login">
Register
</div>
</form>
</section>
jsFiddle
I don't generally like there being two forms in the same place to drive 2 actions. Assuming that you don't need username and password sending to your register page, then I would implement as follows:
<section class="header_form_login">
<form action="index2.html" method="GET">
<label for="user">Usuario:<br></label>
<input type="text" id="user" name="user_input">
<label for="pass"><br>Contraseña:<br></label>
<input type="text" id="pass" name="pass">
<input type="submit" id="login" value="Login">
Registrar
</form>
</section>
CSS for Buttons:
/* BUTTONS */
header > section.header_form_login > form > input#login{
border: none;
background-color: #CAB99F;
color: black;
font-weight: 500;
font-family: 'Roboto';
font-size: 15px;
text-decoration: none;
padding: 10px 20px;
cursor: pointer;
display: inline-block;
margin-top: 10px;
}
header > section.header_form_login > form > input#register{
border: none;
background-color: #CAB99F;
color: black;
font-weight: 500;
font-family: 'Roboto';
font-size: 15px;
text-decoration: none;
padding: 10px 30px;
cursor: pointer;
display: inline-block;
margin-top: 10px;
}

background-color doesn't work when using flexbox

I started using flexbox for my footers and now on all of my pages with forms the background-color is now the default white. Here is an example of one of my pages:
login.php
body {
background-color: #211e1e;
display: flex;
flex-direction: column;
height: 95vh;
}
h1 {
color: #99cc00;
text-align: center;
}
.content {
flex: 1 0 auto;
}
footer {
text-align: center;
font-weight: lighter;
color: #99cc00;
font-size: 10px;
flex-shrink: 0;
}
h3 {
position: absolute;
font-weight: bold;
color: #99cc00;
font-size: 15px;
width: 100%;
top: 91.5%;
}
.button {
background-color: #211e1e;
color: white;
font-size: 24px;
/*padding: 15px 50px;*/
transition-duration: .4s;
border: greenyellow;
width: 250px;
/* width of button */
height: 50px;
/* height of button */
}
.buttonColor:hover {
color: black;
background-color: greenyellow;
}
h1 {
text-align: center;
bottom: 25%;
}
content {
align-items: center;
justify-content: center;
}
.signin {
color: #99cc00;
margin: auto;
font-size: 24px;
}
.loginInput {
font-size: 24px;
}
.loginButton {
background-color: #211e1e;
color: white;
font-size: 24px;
padding: 10px 50px;
transition-duration: .4s;
border: greenyellow;
}
.loginButtonColor:hover {
color: black;
background-color: greenyellow;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" href="../../favicon.ico">
<meta charset="UTF-8">
<title>TapLovers</title>
<link rel="stylesheet" href="../background.css">
<link rel="stylesheet" href="login.css">
</head>
<body>
<div class=content>
<h1><img src="../../36x36-icon.png">apLovers</h1>
<form class="signin">
<input type="text" email="email" placeholder="Email" class="loginInput"><br>
<input type="text" password="password" placeholder="Password" class="loginInput"><br>
<input type="submit" name="submit" id="login" class="loginButton loginButtonColor" value="Login To TapLovers!" /><br><br>
<a href="../register/register.php">
<font color="#99cc00">Create a FREE TapLovers Account!</font>
</a>
</form>
</div>
<footer>
<h3><img src="../../favicon.ico">apLovers</h3><br>&copy 2018 TapLovers, All Rights Reserved
</footer>
</body>
</html>
Also I was trying to center my forms and my title using flexbox as well and I haven't gotten that working either. I'm not really sure what other details would be useful for this particular problem. If you need any more details just reply below and I'll answer them as they come out.
EDIT: The snippet that compiles on stack overflow shows my background just fine. What's more is if I use ctrl+shift+i on my page then the background works but if I just reload on my page then the background will turn white.
I did not see the issue with background fluctuations. I think it is a delay in the page load. I have added comments to help with the flexbox centering of items.
/*CSS reset of browser agent. Removes the horizontal scroll currently happening in page.*/
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: #211e1e;
display: flex;
flex-direction: column;
/* No need to restrict the height.
height: 95vh;*/
}
h1 {
color: #99cc00;
text-align: center;
}
.content {
flex: 1 0 auto;
/*make the content div flex so that the form can take the center alignment from flexbox properties. Add the centering here and avoid the margin: auto property */
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
footer {
text-align: center;
font-weight: lighter;
color: #99cc00;
font-size: 10px;
flex-shrink: 0;
}
h3 {
position: absolute;
font-weight: bold;
color: #99cc00;
font-size: 15px;
width: 100%;
top: 91.5%;
}
.button {
background-color: #211e1e;
color: white;
font-size: 24px;
/*padding: 15px 50px;*/
transition-duration: .4s;
border: greenyellow;
width: 250px;
/* width of button */
height: 50px;
/* height of button */
}
.buttonColor:hover {
color: black;
background-color: greenyellow;
}
h1 {
text-align: center;
bottom: 25%;
}
/*Add flexbox style the inputs as blocks and remove <br> from HTML*/
.signin {
color: #99cc00;
font-size: 24px;
display: flex;
flex-direction: column;
}
.signin>* {
margin: 5px 0;
}
.loginInput {
font-size: 24px;
}
.loginButton {
background-color: #211e1e;
color: white;
font-size: 24px;
padding: 10px 50px;
/*Please check your animation ??
transition-duration: .4s;*/
/*add border size and transparency 1px solid*/
border: 1px solid greenyellow;
}
.loginButtonColor:hover {
color: black;
background-color: greenyellow;
}
<div class="content">
<h1><img src="../../36x36-icon.png">apLovers</h1>
<form class="signin">
<input class="loginInput" placeholder="Email" type="text"> <input class="loginInput" placeholder="Password" type="text"> <input class="loginButton loginButtonColor" id="login" name="submit" type="submit" value="Login To TapLovers!"> <font color="#99CC00">Create a FREE TapLovers Account!</font>
</form>
</div>
<footer>
<h3><img src="../../favicon.ico">apLovers</h3>
<p>© 2018 TapLovers, All Rights Reserved</p>
</footer>

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>