Created a contact form. For making it responsive, i have added a mediquery at 768px to decrease the width of the input field. But it ain't changing.
I will attach the code below for your reference
<div class="form-container">
<h1>send us a message</h1>
<form class="form">
<input id="name" type="text" placeholder="Full Name">
<input id="email" type="text" placeholder="E-Mail">
<textarea id="message" cols="30" rows="10" placeholder="Message"></textarea>
<button type="submit"><i class="fa fa-paper-plane" aria-hidden="true"></i>SEND</button>
</form>
</div>
I used SCSS to style my contact form...
.form-container {
margin: 6rem 0;
height: auto;
h1 {
color: $header-main;
text-align: center;
font-family: $primary-font;
text-transform: capitalize;
font-size: 2.3rem;
letter-spacing: 1px;
&:after {
#include shortBorder(10rem, 1rem, 3px, #111);
margin-bottom: 5rem;
}
}
.form {
input[type="text"],
textarea,button {
display: block;
margin: 2rem auto;
width: 600px;
padding: 1rem;
border-radius: 1rem;
border: 1px solid $plane-white;
box-shadow: 2px 3px 3px 3px #ccc;
outline: none;
transition: width 0.2s ease-in-out;
}
input:hover,
textarea:hover {
width: 620px;
}
::placeholder {
color: rgb(155, 148, 146);
font-weight: 900;
font-family: 'Roboto';
}
button {
background-color: $header-main;
color: $plane-white;
width: 140px;
box-shadow: none;
i {
margin-right: 0.5rem;
}
}
}
button:hover {
cursor: pointer;
width: 160px;
}
}
Media query on contact form.. should decrease to 500px from 600px.
#mediaqueries screen and (max-width:768px) {
.form {
width: 500px;
}
}
There are a bunch of things stopping inputs from shrinking.
You have set rows & columns as size parameters on your text area.
<textarea id="message" cols="30" rows="10" placeholder="Message"></textarea>
This acts as width & height in the HTML. You should remove this and set it with CSS.
Depending on the box-model you're using, margin & padding may be ADDING to the overall width of your elements.
Your media queries aren't targeting the correct elements so it's not being applied as you expect.
Base CSS: (you're changing the width of inputs INSIDE a .form)
.form input[type="text"],
.form textarea,
.form button {
width: 600px;
}
media query (you're changing the form, not the inputs)
.form {
width: 500px;
}
Related
I have a form coded like this I want to make it responsive in both mobile and tablet version or responsive regardless:
</div>
<div class="contact_form">
<form
class="form"
action="https://sheetdb.io/api/v1/it1l3r9npizts"
method="post"
id="sheetdb-form"
>
<label for="name">Name:</label>
<input
type="text"
id="name"
name="data[name]"
placeholder="Your name"
/>
<label for="email">Email:</label>
<input
type="email"
id="email"
name="data[email]"
placeholder="Your email"
/>
<label for="message">Message:</label>
<textarea
id="message"
placeholder="Your message"
rows="6"
name="data[message]"
></textarea>
<div class="center">
<input type="submit" value="Send Message" />
</div>
</form>
</div>
with these styles in css:
.contact_section {
width: 100%;
height: 100%;
}
.contact_form {
display: flex;
align-items: center;
flex-direction: column;
}
.contact_form label {
margin: 15px 0;
}
.contact_form label {
font-size: 20px;
font-weight: 400;
}
.contact_form input,
textarea {
width: 100%;
padding: 10px;
outline: none;
resize: none;
border: none;
border-bottom: 1px solid var(--contrast-color);
}
input[type="text"]:focus,
textarea:focus {
border-bottom: 2px solid var(--main-color);
}
textarea::-webkit-scrollbar {
width: 4px;
}
textarea::-webkit-scrollbar-thumb {
background-color: var(--contrast-color);
}
.center {
text-align: center;
width: 602px;
font-size: 20px;
}
input[type="submit"] {
margin-top: 30px;
width: 100%;
max-width: 200px;
background-color: var(--netural-color);
font-size: 17px;
color: var(--contrast-color);
font-weight: 400;
cursor: pointer;
}
I have been trying to make it responsive cause my form doesn't shrink down and there isn't any padding on the left and right when the screen keeps getting
smaller:
#media screen and (max-width: 768px) {
body {
overflow-x: hidden;
}
.contact_form input textarea {
width: 70%;
margin-top: 0;
.home-section {
height: 100vh;
}
section {
height: 100%;
width: 100%;
}
}
Based on your code I suspect the .center and it's fixed width is setting the width of your form. Just remove that width or make it responsive.
.center {
text-align: center;
width: 602px;
font-size: 20px;
}
<form>
<div class="center">
<input type="submit" value="Send Message" />
</div>
</form>
I have a login form section that I have enclosed inside a div. I want this section of the page only to be styled by the css shown below. However, when I add the css in the style, it isn't applied. I think it is down to syntax. I am trying to add styles within styles.
<div class="login-form">
<form action="/action_page.php" method="post">
<div class="imgcontainer">
<img src="img_avatar2.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label for="psw"><b>Password</b></label>
<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>
The existing css is below (note there is bootstrap enabled and the bottom part of the css is relevant to another part of the site -the intro part and div)
It's in the first part
.login-form {
body {font-family: Arial, Helvetica, sans-serif;}
that I've tried to refer to the div class for the form I want styled.
<style>
.login-form {
body {font-family: Arial, Helvetica, sans-serif;}
form {border: 3px solid #f1f1f1;}
input[type=text], input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
button:hover {
opacity: 0.8;
}
.cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}
.imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
img.avatar {
width: 40%;
border-radius: 50%;
}
.container {
padding: 16px;
}
span.psw {
float: right;
padding-top: 16px;
}
}
.intro-text {
width: 1000px;
padding:15px;
margin:40;
}
Can someone point out the error with some best practices on applying several styles to one div. I have already applied styles correctly, as can be seen with the
intro-text {
width: 1000px;
padding:15px;
margin:40;
}
which is correctly applied to:
<div class="intro-text">
<h1 class="display-5">Login</h1>
<p>Welcome back</p>
</div>
I cannot figure out how to apply the more complex styles to just the login-form div class and have tried several things.
The css you have is not valid. You cannot nest css blocks like that. I would recommend take a look at the css selectors.
Let's say you want to target a button inside the div with class login-form. Instead of doing this:
.login-form{
button{
//this doesn't work
}
}
You should do this:
.login-form button{
//css here
}
.login-form {
font-family: Arial, Helvetica, sans-serif;
}
.login-form form {border: 3px solid #f1f1f1;}
.login-form input[type=text], .login-form input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
.login-form button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
.login-form button:hover {
opacity: 0.8;
}
.login-form .cancelbtn {
width: auto;
padding: 10px 18px;
background-color: #f44336;
}
.login-form .imgcontainer {
text-align: center;
margin: 24px 0 12px 0;
}
.login-form img.avatar {
width: 40%;
border-radius: 50%;
}
.login-form .container {
padding: 16px;
}
.login-form span.psw {
float: right;
padding-top: 16px;
}
.intro-text {
width: 1000px;
padding:15px;
margin:40;
}
Here is a snippet with the proper css:
<link rel="stylesheet" href="style.css">
<div class="login-form">
<form action="/action_page.php" method="post">
<div class="imgcontainer">
<img src="img_avatar2.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label for="psw"><b>Password</b></label>
<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>
</form>
</div>
Syntax use is not correct , nesting in css shoud be in you case like
.login-form form {
// css code here
}
so apply selector and space and other selector for nesting properties
so every css rules in your code to be applyed only to this page , should be preceded with parent selector (.login-form) in your case .
but for the body , it cant be applied by this way ,
to apply some font for only this page , you could use by example :
adding class to body in this page then apply css as :
<body class="login-page">
// rest of html
</body>
and css should be :
body.login-page {font-family: Arial, Helvetica, sans-serif;}
Also I forget to mention that the syntax you used before, is like the scss syntax, but it should be precompiled to browser understandable css formt , thus you project should as modern web project to precompile scss to css .
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.
New coder here. I have a form that is scaled exactly how I want on web, but looks horrible on mobile. The form isn't scaling down. I would like the form to scale down based on a mobile devices width. Any thoughts or suggestions would be much appreciated. I have included the HTML and CSS I have below. Thank you! Also, I would prefer to do this in CSS.
HTML:
<div class="contactForm">
<form id="form" class="topBefore" method="POST" action="#">
<input id="name" type="text" name="name" placeholder="NAME">
<input id="phone" type="tel" name="phone" placeholder="PHONE">
<input id="email" type="email" name="email" placeholder="E-
MAIL">
<textarea id="messagebody" type="text" name="message"
placeholder="MESSAGE"></textarea>
<input id="submit" type="submit" name="send" value="SEND">
</form>
</div>
CSS:
.contactForm {
background-color: #FAFAFA;
width: 100%;
margin: 0 auto;
}
#form {
position: relative;
width: 500px;
margin: 0 auto;
padding-bottom: 20px;
}
input {
width: 470px;
height: 50px;
padding: 0px 15px 0px 15px;
background: transparent;
outline: none;
font-size: 14px;
color: black;
border: solid 2px #dddddd;
border-bottom: none;
letter-spacing: 2px;
background-color: white;
}
input:hover {
background: #f4f4f4;
font-size: 14px;
color: black;
letter-spacing: 2px;
border-color: #e5e5e5;
}
textarea {
width: 470px;
max-width: 470px;
height: 110px;
max-height: 110px;
padding: 15px;
letter-spacing: 2px;
background: transparent;
outline: none;
font-size: 14px;
color: #333;
background-color: white;
border: solid 1px #dddddd;
border: solid 2px #dddddd;
}
textarea:hover {
background: #f4f4f4;
color: black;
}
#submit {
width: 504px;
padding: 0;
margin: -6px 0px 0px 0px;
font-family: 'Lato', sans-serif;
font-size: 14px;
color: #333;
outline:none;
cursor: pointer;
border-top: none;
letter-spacing: 3px;
border: solid 2px #dddddd;
}
#submit:hover {
background-color: #7fbf7f;
color: black;
letter-spacing: 3px;
font-size: 15px;
border-color: #7fbf7f;
}
Try using media queries:
Media queries are useful when you want to apply CSS styles depending on a device's general type (such as print vs. screen), specific characteristics (such as the width of the browser viewport), or environment (such as ambient light conditions). With the huge variety of internet-connected devices available today, media queries are a vital tool for building websites and apps that are robust enough to work on whatever hardware your users have.
Example:
#media screen and (max-width: 699px) and (min-width: 520px)
Put this in your head tag:
<meta name="viewport" content="width=device-width, initial-scale=1">
This means that the browser will (probably) render the width of the page at the width of its own screen. So if that screen is 320px wide, the browser window will be 320px wide, rather than way zoomed out and showing 960px (or whatever that device does by default, in lieu of a responsive meta tag).
For more information:
https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
Also: https://css-tricks.com/snippets/html/responsive-meta-tag/
Use mobile query: allows specified CSS to be applied depending on the device https://responsivedesign.is/develop/browser-feature-support/media-queries-for-common-device-breakpoints/
You can use this common device breakpoints.
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>