At first my input focus was working just fine, now all of a sudden when I add a couple of more styles to my input, it suddenly stops working. I've only added the 'input[type="text"] and border-radius and padding and some margins since when it was working. When you click each form element, nothing happens even though I have a rule for focus(which you can find near the bottom of the code). Is there any workaround for this?
form{
position: absolute;
left: 50%;
color: white;
margin-left: -180px;
padding: 15px 30px 15px 30px;
background-color: #26004d;
border-radius: 7px;
margin-top: 10px;
width: 300px;
}
label{
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
}
input:focus {
border: 2px solid #862d59;
}
input[type="submit"]{
width: 50%;
background-color: #862d59;
color: white;
margin-top: 5px;
padding: 12px 12px;
border: none;
cursor: pointer;
}
input[type="text"]{
width: 100%;
padding: 12px 12px;
margin: 4px 0;
border: 1px solid #ccc;
border-radius: 6px;
//box-sizing: border-box;
}
<div id="formholder1">
<form>
<div class="single-field">
<label for="Username">Username:</label>
<input name="Name" type="text"></input>
</div>
<div class="single-field">
<label for="Password">Password:</label>
<input name="Password" type="text"></input>
</div>
<input type="submit" value="Login">
</form>
</div>
Use this input[type="text"]:focus {
border: 2px solid #862d59;
}
learn it - http://www.w3schools.com/cssref/trysel.asp?selector=:focus
example - https://css-tricks.com/snippets/css/glowing-blue-input-highlights/
now its working
form{
position: absolute;
left: 50%;
color: white;
margin-left: -180px;
padding: 15px 30px 15px 30px;
background-color: #26004d;
border-radius: 7px;
margin-top: 10px;
width: 300px;
}
label{
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
}
input[type="text"]:focus {
border: 2px solid #862d59;
}
input:focus {
border: 2px solid red;
}
input[type="submit"]{
width: 50%;
background-color: #862d59;
color: white;
margin-top: 5px;
padding: 12px 12px;
border: none;
margin-left:-10px;
cursor: pointer;
}
input[type="text"]{
width: 100%;
padding: 12px 12px;
margin: 4px 0;
border: 1px solid #ccc;
border-radius: 6px;
margin-left:-15px;
//box-sizing: border-box;
}
<div id="formholder1">
<form>
<div class="single-field">
<label for="Username">Username:</label>
<input name="Name" type="text"></input>
</div>
<div class="single-field">
<label for="Password">Password:</label>
<input name="Password" type="text"></input>
</div>
<input type="submit" value="Login">
</form>
</div>
Put Your :focus property after input.
input[type="text"]:focus {
border: 5px solid #862d59;
}
form{
position: absolute;
left: 50%;
color: white;
margin-left: -180px;
padding: 15px 30px 15px 30px;
background-color: #26004d;
border-radius: 7px;
margin-top: 10px;
width: 300px;
}
label{
float: left;
text-align: right;
margin-right: 15px;
width: 100px;
}
input[type="submit"]{
width: 50%;
background-color: #862d59;
color: white;
margin-top: 5px;
padding: 12px 12px;
border: none;
cursor: pointer;
}
input[type="text"]{
width: 100%;
padding: 12px 12px;
margin: 4px 0;
border: 1px solid #ccc;
border-radius: 6px;
box-sizing: border-box;
}
input[type="text"]:focus {
border: 5px solid #862d59;
}
<div id="formholder1">
<form>
<div class="single-field">
<label for="Username">Username:</label>
<input name="Name" type="text"></input>
</div>
<div class="single-field">
<label for="Password">Password:</label>
<input name="Password" type="text"></input>
</div>
<input type="submit" value="Login">
</form>
</div>
Related
I'm currently working on a calculator in HTML and have made a form to input various numbers. The form is located in a div that's a sidebar, and I've made a div for each row holding an input and label. However, the input elements are left with a lot of space above them, as well as the borders as they're attached to the input elements. How could I allow the inputs to take up all available vertical space? Picture of extra space
.sidebar {
background-color: #272640;
float: left;
width: 20%;
height: 100%;
position: fixed;
box-sizing: border-box;
display: flex;
flex-direction: column;
border: 1px solid #3E1F47;
}
#sidebarCentered {
}
.siderow {
background-color: #312244;
border-top: 1px solid #3E1F47;
color: white;
padding: 10px;
box-sizing: border-box;
width: 50% text-align:center;
font-family: monaco;
}
.siderow label {}
.siderow input {
box-sizing: border-box;
background-color: #312244;
border: 0px;
height: 100%;
border-left: 1px solid #5A5766;
color: white;
width: 50%;
float: right;
text-align: center;
}
.sidebarbuttons {
background-color: #312244;
margin-top: 10%;
}
.sidebarbuttons input {
background-color: #312244;
font-family: monaco;
font-size: 15px;
margin: 5px;
width: 45%;
color: white;
padding: 10px;
border: 1px solid #3E1F47;
border-radius: 10px;
transition: all ease-in-out 0.15s;
}
.sidebarbuttons input:hover {
background-color: #272640;
color: #272640;
transition: all ease-in-out 0.15s;
}
#centermenu {
background-color: #212F45;
color: #EDFFEC;
overflow: hidden;
text-decoration: none;
border-bottom: 1px solid #5A5766;
box-sizing: border-box;
}
<div class="sidebar">
<form id="sidebarCentered">
<div class="siderow">
<label for="balance">Balance:</label>
<input type="number" name="balance" value=500>
</div>
<div class="siderow">
<label for="monthly">Monthly <br> contribution:</label>
<input type="number" name="monthly" value=0>
</div>
<div class="siderow">
<label for="nummonths">Number of <br> Months:</label>
<input type="number" name="nummonths" value=12>
</div>
<div class="siderow" style="border-bottom:1px solid #3E1F47;">
<label for="ror">Monthly Rate <br> of Return:</label>
<input type="number" name="ror" value=1>
</div>
<div class="sidebarbuttons">
<input type="button" value="Calculate" style="float:left;">
<input type="button" value="Quit" style="float:right;">
</div>
</form>
</div>
That space is caused by padding of 10px in .siderow. I changed the padding to 0 10px which sets top and bottom padding to zero and left/right to 10px. I also added min-width: 200px; to .sidebar for clarity. You may want to change that. Extra vertical space has been removed.
.sidebar {
background-color: #272640;
float: left;
width: 20%;
min-width: 200px;
height: 100%;
position: fixed;
box-sizing: border-box;
display: flex;
flex-direction: column;
border: 1px solid #3E1F47;
}
#sidebarCentered {
}
.siderow {
background-color: #312244;
border-top: 1px solid #3E1F47;
color: white;
padding: 0 10px; /* changed here */
box-sizing: border-box;
width: 50% text-align:center;
font-family: monaco;
}
.siderow label {}
.siderow input {
box-sizing: border-box;
background-color: #312244;
border: 0px;
height: 100%;
border-left: 1px solid #5A5766;
color: white;
width: 50%;
float: right;
text-align: center;
}
.sidebarbuttons {
background-color: #312244;
margin-top: 10%;
}
.sidebarbuttons input {
background-color: #312244;
font-family: monaco;
font-size: 15px;
margin: 5px;
width: 45%;
color: white;
padding: 10px;
border: 1px solid #3E1F47;
border-radius: 10px;
transition: all ease-in-out 0.15s;
}
.sidebarbuttons input:hover {
background-color: #272640;
color: #272640;
transition: all ease-in-out 0.15s;
}
#centermenu {
background-color: #212F45;
color: #EDFFEC;
overflow: hidden;
text-decoration: none;
border-bottom: 1px solid #5A5766;
box-sizing: border-box;
}
<div class="sidebar">
<form id="sidebarCentered">
<div class="siderow">
<label for="balance">Balance:</label>
<input type="number" name="balance" value=500>
</div>
<div class="siderow">
<label for="monthly">Monthly <br> contribution:</label>
<input type="number" name="monthly" value=0>
</div>
<div class="siderow">
<label for="nummonths">Number of <br> Months:</label>
<input type="number" name="nummonths" value=12>
</div>
<div class="siderow" style="border-bottom:1px solid #3E1F47;">
<label for="ror">Monthly Rate <br> of Return:</label>
<input type="number" name="ror" value=1>
</div>
<div class="sidebarbuttons">
<input type="button" value="Calculate" style="float:left;">
<input type="button" value="Quit" style="float:right;">
</div>
</form>
</div>
Give .siderow padding of 0 and add a height to .siderow input and .siderow label.
Next, delete those br tags and add flex to .siderow label so it can be vertically aligned in the middle. Also, don't use inline css.
In all, you will have this:
<div class="sidebar">
<form id="sidebarCentered">
<div class="siderow">
<label for="balance">Balance:</label>
<input type="number" name="balance" value=500>
</div>
<div class="siderow">
<label for="monthly">Monthly contribution:</label>
<input type="number" name="monthly" value=0>
</div>
<div class="siderow">
<label for="nummonths">Number of Months:</label>
<input type="number" name="nummonths" value=12>
</div>
<div class="siderow">
<label for="ror">Monthly Rate of Return:</label>
<input type="number" name="ror" value=1>
</div>
<div class="sidebarbuttons">
<input type="button" value="Calculate" style="float:left;">
<input type="button" value="Quit" style="float:right;">
</div>
</form>
</div>
and the CSS
.sidebar {
background-color: #272640;
float: left;
width: 400px;
height: 100%;
position: fixed;
box-sizing: border-box;
display: flex;
flex-direction: column;
border: 1px solid #5A5766;
}
#sidebarCentered {
}
.siderow {
border-top: 1px solid #5A5766;
color: white;
padding: 0;
box-sizing: border-box;
width: 100%;
text-align:center;
font-family: monaco;
height: auto;
float: left;
}
.siderow:first-child {
border-top: none;
}
.siderow:nth-child(4) {
border-bottom: 1px solid #5A5766;
}
.siderow label {
width: calc(50% - 5px);
float: left;
height: 40px;
display: flex;
align-items: center;
margin-left: 5px;
}
.siderow input {
box-sizing: border-box;
background-color: #272640;
border: 0;
height: 100%;
border-left: 1px solid #5A5766;
color: white;
width: 50%;
float: left;
text-align: center;
height: 40px;
}
.sidebarbuttons {
margin-top: 10%;
}
.sidebarbuttons input {
background-color: #888;
font-family: monaco;
font-size: 15px;
margin: 5px;
width: 45%;
color: white;
padding: 10px;
border: 1px solid #5A5766;
border-radius: 10px;
transition: all ease-in-out 0.15s;
}
.sidebarbuttons input:hover {
background-color: #ccc;
color: #272640;
transition: all ease-in-out 0.15s;
}
#centermenu {
background-color: #212F45;
color: #EDFFEC;
overflow: hidden;
text-decoration: none;
border-bottom: 1px solid #5A5766;
box-sizing: border-box;
}
Link to Fiddle for reference https://jsfiddle.net/kavyw86d/
As you can see on the snippet, I've got spacing on the corners somehow. I need to remove spacing and make it look like a regular border. That's it
form {
width: 400px;
height: 50px;
display: flex;
flex-direction: row;
border: solid #D3D8E0 1px;
margin-bottom: 0px;
border-radius: 8px;
}
input[type="email"] {
flex-grow: 2;
margin: 0px;
padding: 0px;
width: 100%;
border: none;
}
input[type="submit"] {
height: 44px;
background: #0CB66E;
color: #fff;
font-size: 15px;
font-weight: 600;
border: none;
border-radius: 6px;
margin: 3px 3px 0 0;
}
input[type="email"]:focus {
outline: none;
}
<form id="form" action="https://www.freecodecamp.com/email-submit" method="GET">
<input id="email" type="email" placeholder="Email" required>
<input id="submit" type="submit" value="Get started">
</form>
You forgot to add a border-radius on your input type email.
form {
width: 400px;
height: 50px;
display: flex;
flex-direction: row;
border: solid #D3D8E0 1px;
margin-bottom: 0px;
border-radius: 8px;
}
input[type="email"] {
flex-grow: 2;
margin: 0px;
padding: 0px;
width: 100%;
border: none;
border-radius: 8px;
}
input[type="submit"] {
height: 44px;
background: #0CB66E;
color: #fff;
font-size: 15px;
font-weight: 600;
border: none;
border-radius: 6px;
margin: 3px 3px 0 0;
}
input[type="email"]:focus {
outline: none;
}
<form id="form" action="https://www.freecodecamp.com/email-submit" method="GET">
<input id="email" type="email" placeholder="Email" required>
<input id="submit" type="submit" value="Get started">
</form>
The input[type="email"] has a border-radius of 0 so cuts through it. Change it to this:
input[type="email"] {
flex-grow: 2;
margin: 0px;
padding: 0px;
width: 100%;
border: none;
border-radius: 6px;
}
input[type="email"] {
flex-grow: 2;
margin: 0px;
padding: 0px;
width: 100%;
border: none;
border-radius: 6px 0 0 6px;
}
How do I adjust the text input position in the input box? I did do input[type=text] but it messes up my input box's position completely. I did change my ::placeholder left margin a little bit in case if you want to know.
HTML & CSS
.registerbox {
width: 500px;
height: 450px;
background: rgba(255, 255, 255, 0.7);
margin: 10px auto;
border-radius: 20px;
box-shadow: 0 0 40px 10px rgba(0, 0, 0, 0.6);
color: white;
}
.inner-registerbox {
position: relative;
width: 100%;
height: 100%;
}
.registerbox-front {
position: absolute;
height: 100%;
width: 100%;
padding: 55px;
box-sizing: border-box;
border-radius: 14px;
}
input label {
display: block;
}
.registerbox h2 {
text-align: center;
font-size: 25px;
font-weight: normal;
margin-bottom: 20px;
margin-top: 0;
color: black;
}
.input-box2 {
width: 95%;
background: transparent;
border: 1px solid black;
height: 32px;
border-radius: 5px;
padding: 0 0px;
box-sizing: border-box;
outline: none;
text-align: left;
color: black;
display: table;
margin-top: 2px;
margin-bottom: 15px;
}
.input-box3 {
width: 105%;
background: transparent;
border: 1px solid black;
height: 32px;
border-radius: 5px;
padding: 0 0px;
box-sizing: border-box;
outline: none;
text-align: left;
color: black;
display: table;
margin-top: 2px;
margin-bottom: 15px;
}
.registerbox-front ::placeholder {
padding-left: 10px;
}
.box-firstline, .box-secondline {
margin-top: 10px
}
<body>
<div class="registerbox">
<div class="inner-registerbox">
<div class="registerbox-front">
<h2>BORANG PENDAFTARAN MURID</h2>
<form>
<section>
<div class="box-firstline">
<div style="float:left;margin-right:25px;">
<label for="idmurid">ID Murid</label> <br />
<input type="text" name="idmurid" class="input-box2" placeholder="ID Murid" required>
</div>
<div style="float:left;">
<label for="namamurid">Nama Murid</label> <br />
<input type="text" name="namamurid" class="input-box3" placeholder="Nama Murid" required>
</div>
</div>
<br style="clear:both;" />
</section>
<div class="box-secondline">
<div style="float:left;margin-right:25px;">
<label for="namakelas">Nama Kelas</label> <br />
<input type="text" name="namakelas" class="input-box2" placeholder="Nama Kelas" required>
</div>
<div style="float:left;">
<label for="katalaluan_murid">Kata Laluan</label> <br />
<input type="password" name="katalaluan_murid" class="input-box3" placeholder="Katalaluan" required>
</div>
<br style="clear:both;" />
</div>
</div>
</div>
</body>
I took the code you posted, removed the ::placeholder padding and then added
input[type="text"] {
padding-left: 10px;
}
input[type="password"] {
padding-left: 10px;
}
And it adjusted the the text to match the placeholder.
Here is the full CSS:
.registerbox {
width: 500px;
height: 450px;
background: rgba(255, 255, 255, 0.7);
margin: 10px auto;
border-radius: 20px;
box-shadow: 0 0 40px 10px rgba(0, 0, 0, 0.6);
color: white;
}
input[type="text"] {
padding-left: 10px;
}
input[type="password"] {
padding-left: 10px;
}
.inner-registerbox {
position: relative;
width: 100%;
height: 100%;
}
.registerbox-front {
position: absolute;
height: 100%;
width: 100%;
padding: 55px;
box-sizing: border-box;
border-radius: 14px;
}
input label {
display: block;
}
.registerbox h2 {
text-align: center;
font-size: 25px;
font-weight: normal;
margin-bottom: 20px;
margin-top: 0;
color: black;
}
.input-box2 {
width: 95%;
background: transparent;
border: 1px solid black;
height: 32px;
border-radius: 5px;
padding: 0 0px;
box-sizing: border-box;
outline: none;
text-align: left;
color: black;
display: table;
margin-top: 2px;
margin-bottom: 15px;
}
.input-box3 {
width: 105%;
background: transparent;
border: 1px solid black;
height: 32px;
border-radius: 5px;
padding: 0 0px;
box-sizing: border-box;
outline: none;
text-align: left;
color: black;
display: table;
margin-top: 2px;
margin-bottom: 15px;
}
.box-firstline, .box-secondline {
margin-top: 10px;
}
I'm sure this is something simple but i'm exhausted trying to figure it out. I've tried a lot of different variations and I just can't get the search button to sit on the same line as the search bar. I'm at my wits end. Why are they on two different lines???
.container-inner {
width: 100%;
position: relative;
display: flex;
}
#search-bar {
width: 90%;
border: 2px solid #fff200;
border-right: none;
padding: 5px;
height: 40px;
border-radius: 5px 0 0 5px;
outline: none;
color: #9DBFAF;
}
#search-bar:focus{
color: black;
}
.searchButton {
width: 40px;
height: 36px;
border: 2px solid #fff200;
background: grey;
text-align: center;
color: black;
border-radius: 0 5px 5px 0;
cursor: pointer;
font-size: 20px;
}
.searchButton:hover{
background: darkslategrey
}
.container {
width: 50%;
position: absolute;
top: 20%;
left: 50%;
transform: translate(-50%, -50%);
}
<div class="container">
<div class="container-inner">
<form id="search-form">
<div class="input-group input-group-lg">
<input id="search-bar" class="form-control search-bar" placeholder="Search for a song...">
<button type="submit" class="searchButton">
<i class="fa fa-search" aria-hidden="true"></i>
</div>
</div>
</form>
</div>
You should change add a wrapper with display flex, set the property flex of #search-bar to 1 and remove the height from the #search-bar as in the following example.
.container-inner {
width: 100%;
position: relative;
display: flex;
}
#search-bar {
border: 2px solid #fff200;
border-right: none;
padding: 5px;
border-radius: 5px 0 0 5px;
outline: none;
color: #9DBFAF;
flex: 1;
}
#search-bar:focus {
color: black;
}
.searchButton {
width: 40px;
height: 36px;
border: 2px solid #fff200;
background: grey;
text-align: center;
color: black;
border-radius: 0 5px 5px 0;
cursor: pointer;
font-size: 20px;
}
.searchButton:hover {
background: darkslategrey
}
.container {
width: 50%;
position: absolute;
top: 20%;
left: 50%;
transform: translate(-50%, -50%);
}
.input-wrapper {
display: flex;
}
<div class="container">
<div class="container-inner">
<form id="search-form">
<div class="input-group input-group-lg input-wrapper">
<input id="search-bar" class="form-control search-bar" placeholder="Search for a song...">
<button type="submit" class="searchButton">
<i class="fa fa-search" aria-hidden="true"></i>
</button>
</div>
</form>
</div>
</div>
Give .input-group display: flex;
.container-inner {
width: 100%;
position: relative;
display: flex;
}
#search-bar {
width: 90%;
border: 2px solid #fff200;
border-right: none;
padding: 5px;
height: 40px;
border-radius: 5px 0 0 5px;
outline: none;
color: #9DBFAF;
}
#search-bar:focus{
color: black;
}
.searchButton {
width: 40px;
height: 36px;
border: 2px solid #fff200;
background: grey;
text-align: center;
color: black;
border-radius: 0 5px 5px 0;
cursor: pointer;
font-size: 20px;
}
.searchButton:hover{
background: darkslategrey
}
.input-group{
display: flex;
}
<div class="container">
<div class="container-inner">
<form id="search-form">
<div class="input-group input-group-lg">
<input id="search-bar" class="form-control search-bar" placeholder="Search for a song...">
<button type="submit" class="searchButton">
<i class="fa fa-search" aria-hidden="true"></i>
</div>
</div>
</form>
</div>
Your width on searchBar of width: 90%; is taking up too much space. 90% of the parent + it's own padding is leaving less than 40px; needed for the button to sit alongside. Remove the width of the searchBar or make it less like 70% etc.
.container-inner {
width: 100%;
position: relative;
display: flex;
}
#search-bar {
border: 2px solid #fff200;
border-right: none;
padding: 5px;
height: 40px;
border-radius: 5px 0 0 5px;
outline: none;
color: #9DBFAF;
}
#search-bar:focus{
color: black;
}
.searchButton {
width: 40px;
height: 36px;
border: 2px solid #fff200;
background: grey;
text-align: center;
color: black;
border-radius: 0 5px 5px 0;
cursor: pointer;
font-size: 20px;
}
.searchButton:hover{
background: darkslategrey
}
.container {
width: 50%;
position: absolute;
top: 20%;
left: 50%;
transform: translate(-50%, -50%);
}
<div class="container">
<div class="container-inner">
<form id="search-form">
<div class="input-group input-group-lg">
<input id="search-bar" class="form-control search-bar" placeholder="Search for a song...">
<button type="submit" class="searchButton">
<i class="fa fa-search" aria-hidden="true"></i>
</div>
</div>
</form>
</div>
try changing that display attribute for the inner container
I made this simple css design for my web form, and the problem is that on mobile or any small screen the input and the captcha escape from the frame yet the submit button is just fine... I don't know how to fix this and I have little experience in css.
Here's what it looks like on mobile:
and here's my code:
* {
margin: 0px;
padding: 0px;
}
body {
font-size: 120%;
background: white;
}
form,
.dis {
width: 30%;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
input {
color: black;
padding: 5px;
width: auto;
border: 2px solid black;
border-radius: 10px 10px 10px 10px;
text-align: center;
background: white;
}
h2 {
width: 20%;
margin: 10px auto;
padding: 15px;
border: 2px solid red;
font-size: 75%;
color: red;
text-align: center;
}
<form id="dis" method="post">
<input name="username" type="username" placeholder="What's your Discord tag?" size="40"><br><br>
<input type="submit" name="submit" value="Submit"><br><br>
<center>
<div class="g-recaptcha" data-sitekey="6LfVs6sUAAAAAHi-Pm9QAKHNk_QskSE_-8F5zBrV"></div>
</center>
</form>
You can reset the value of your size attribute , or set a width to your input text. size="30" seems fine here , but to avoid side effects from font-size or family, i would advise to set also a max-width in your css.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text#size
The size attribute is a numeric value indicating how many characters wide the input field should be. The value must be a number greater than zero, and the default value is 20. Since character widths vary, this may or may not be exact and should not be relied upon to be so; the resulting input may be narrower or wider than the specified number of characters, depending on the characters and the font (font settings in use).
* {
margin: 0px;
padding: 0px;
}
body {
font-size: 120%;
background: white;
}
form,
.dis {
width: 30%;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
input {
color: black;
padding: 5px;
width: auto;
border: 2px solid black;
border-radius: 10px 10px 10px 10px;
text-align: center;
background: white;
max-width:90%;
}
h2 {
width: 20%;
margin: 10px auto;
padding: 15px;
border: 2px solid red;
font-size: 75%;
color: red;
text-align: center;
}
<form id="dis" method="post">
<input name="username" type="username" placeholder="What's your Discord tag?" size="30"><br><br>
<input type="submit" name="submit" value="Submit"><br><br>
<center>
<div class="g-recaptcha" data-sitekey="6LfVs6sUAAAAAHi-Pm9QAKHNk_QskSE_-8F5zBrV"></div>
</center>
</form>
The stylish rule you are missing on your css input is the max-width property :
* {
margin: 0px;
padding: 0px;
}
body {
font-size: 120%;
background: white;
}
form,
.dis {
width: 30%;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
input {
color: black;
padding: 5px;
width: auto;
max-width: 95%;
border: 2px solid black;
border-radius: 10px 10px 10px 10px;
text-align: center;
background: white;
}
h2 {
width: 20%;
margin: 10px auto;
padding: 15px;
border: 2px solid red;
font-size: 75%;
color: red;
text-align: center;
}
<form id="dis" method="post">
<input name="username" type="username" placeholder="What's your Discord tag?" size="30"><br><br>
<input type="submit" name="submit" value="Submit"><br><br>
<center>
<div class="g-recaptcha" data-sitekey="6LfVs6sUAAAAAHi-Pm9QAKHNk_QskSE_-8F5zBrV"></div>
</center>
</form>
Try to use this, all I have done just adding box-sizing: border-box and width: 100% into input
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body {
font-size: 120%;
background: white;
}
#media only screen and (max-width: 999px) {
form,
.dis {
width: 30%;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
}
#media only screen and (min-width: 1000px) {
form,
.dis {
width: 300px;
margin: 10px auto;
padding: 20px;
border: 3px solid #333333;
background: white;
border-radius: 5px 5px 10px 10px;
text-align: center;
}
}
input {
color: black;
padding: 5px;
width: 100%;
border: 2px solid black;
border-radius: 10px 10px 10px 10px;
text-align: center;
background: white;
}
h2 {
width: 20%;
margin: 10px auto;
padding: 15px;
border: 2px solid red;
font-size: 75%;
color: red;
text-align: center;
}
<form id="dis" method="post">
<input name="username" type="username" placeholder="What's your Discord tag?" size="40"><br><br>
<input type="submit" name="submit" value="Submit"><br><br>
<center>
<div class="g-recaptcha" data-sitekey="6LfVs6sUAAAAAHi-Pm9QAKHNk_QskSE_-8F5zBrV"></div>
</center>
</form>