CSS spacing is off, not sure what's causing - html

I'm working on a form and need to include a note above the reCAPTCHA field. I've got everything in place, but the spacing between the *To submit your message, please type the words shown below: note and reCAPTCHA is way off, I need to figure out how to bring the two elements closer together vertically.
I'm using a paragraph tag in the form for the note, I'm not sure if that's bad form??
Website Link
CSS:
/*Prayer Request Form*/
#prayer-form {
margin-bottom: 20px;
width: 960px;
height: 520px;
padding: 40px 30px;
margin-left: auto;
margin-right: auto;
}
form, fieldset, input, textarea {
margin: 0; padding: 0; border: 0; outline: none;
}
label {
float: left; clear: left; margin: 11px 20px 0 0; width: 65px;
text-align: left; font-size: 14px; color: #000000;
}
input {
width: 370px; height: 20px; padding: 5px 10px 5px 10px; margin: 0 0 23px 0;
background: #EDEDED;
border: 1px solid #808080;
font-family: sans-serif; font-size: 14px; color: #000000;
}
textarea {
width: 650px; height: 120px; padding: 10px 10px 5px 10px; margin: 0 0 20px 0;
background: #EDEDED;
border: 1px solid #808080;
overflow: auto;
font-family: sans-serif; font-size: 14px; color: #000000;
}
input[type=submit] {
width: 95px; height: 30px; float: left; clear: left; padding: 2px 5px 2px 5px; margin: 20px 0 0 85px;
color: #FFFFFF;
border: 1px solid #0000CD;
background: -moz-linear-gradient(top, #00BFFF 0%, #0000CD 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#00BFFF), color-stop(100%,#0000FF)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#00BFFF', endColorstr='#0000CD');
cursor: pointer;
}
input[type=reset] {
width: 95px; height: 30px; float: left; padding: 2px 5px 2px 5px; margin: 20px 0 0 20px;
border: 1px solid #858585;
background: -moz-linear-gradient(top, #EDEDED 0%, #999999 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#EDEDED), color-stop(100%,#999999)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#EDEDED', endColorstr='#999999');
cursor: pointer;
}
p captcha{
float: left; padding: 2px 0 0 85px;
font-family: sans-serif; font-size: 14px; color: #000000;
}
#captcha {
float: left; margin: 11px 0 20px 0; width: 445px; height: 110px; padding: 2px 5px 2px 85px;
}
HTML:
<!--/ Show Prayer Request Form-->
<div id="prayer-form">
<form name="prayer-form" action="send-mail.php" method="POST">
<label for="field_name">Name:</label> <input type="text" id="field_name" name="sender_name" placeholder="First Name, Last Name">
<br>
<label for="field_email">Email:</label> <input type="text" id="field_email" name="sender_email" placeholder="example#domain.com">
<br>
<label for="field_phone">Phone:</label> <input type="text" id="field_phone" name="sender_phone" placeholder="(444) 444-4444">
<br>
<label for="field_message">Prayer Request:</label>
<textarea id="field_message" name="sender_message" placeholder="How can we pray for you?"></textarea>
<p id="captcha"><b>*To submit your message, please type the words shown below:</b></p>
<div id="captcha">
<?php
require_once('recaptchalib.php');
$publickey = "*****************AzBk";
echo recaptcha_get_html($publickey);
?>
</div>
<input type="submit" name="send_message" value="Submit"> <input type="reset" value="Reset">
</form>
</div>
Your help is much appreciated.

You need to adjust the following rule in your style sheet:
#captcha {
float: left;
margin: 11px 0 20px 0;
width: 445px;
height: 110px;
padding: 2px 5px 2px 85px;
}
You don't need to specify the height, just use height: auto or omit it all together.
You can also omit the padding, using margin alone will give you enough control.
Finally, you may not need to float the paragraph.

It looks like it's the height setting in your captcha CSS:
#captcha {
float: left;
margin: 11px 0 20px 0;
width: 445px;
height: 110px;
padding: 2px 5px 2px 85px;
}
When I disable the height setting of 110px, the spacing is more reasonable.

I think that you have set your with the same id as the actual captcha form you must change the id on the tag, plus it is not good to have 2 ID's.
change to this -
<p id="captcha-notice"><b>*To submit your message, please type the words shown below:</b></p>
<div id="captcha">
<?php
require_once('recaptchalib.php');
$publickey = "*****************AzBk";
echo recaptcha_get_html($publickey);
?>
</div>
then add your styles
#captcha-notice{
/* styles */
}

Simple, change this css code:
#captcha {
float: left;
height: 110px;
margin: 11px 0 20px;
padding: 2px 5px 2px 85px;
width: 445px;
}
to
#captcha {
float: left;
/*height: 110px;
margin: 11px 0 20px;*/
padding: 2px 5px 2px 85px;
width: 445px;
}

Related

How do I add a red asterisk in the placeholder?

I was building a form with questions in the placeholder.
Now I want a red asterisk for the required fields.
Normally we could use span for giving different styles to the asterisk, but in my case, I can't add span in the placeholder.
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
height: auto;
margin: 8% auto;
background: #fff;
border-radius: 15px;
position: relative;
padding: 90px 0;
overflow: auto;
}
h2 {
text-align: center;
margin-bottom: 80px;
color: #333;
}
.container form {
width: 280px;
text-align: center;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
form input {
width: 100%;
padding: 10px 5px;
margin: 10px 0;
border: 0;
border-bottom: 1px solid #999;
outline: none;
background: transparent;
}
::placeholder {
color: #777;
}
.btn-box {
width: 100%;
margin: 30px auto 30px auto;
text-align: center;
}
<div class="container">
<form class="form1">
<h2>Let's Start Building!</h2>
<input type="email" placeholder="E-mail" required>
<div class="btn-box">
<button class="BN" type="button">Next</button>
</div>
</form>
</div>
https://paulund.co.uk/add-required-asterisk-with-css
Is there a way can use this website's method in my code?
This is not ideal, but since you said you can't add elements and didn't mention using JS, I tried a css only solution...again, not an ideal situation. I don't know what happens before or after this page. I added the asterisk using a ::before on the div containing the button and setting it to be position:relative, while the asterisk is set as position:absolute and moved next to the input field. I'm ready for the pitchforks and torches.
/*---------------------------------*/
input[type="email"][required]+.btn-box::before {
content: "*";
color: red;
display: block;
position: absolute;
top: -70px;
left: -10px;
}
input[type="email"][required]+.btn-box {
position: relative;
}
/*---------------------------------*/
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
height: auto;
margin: 8% auto;
background: #fff;
border-radius: 15px;
position: relative;
padding: 90px 0;
overflow: auto;
}
h2 {
text-align: center;
margin-bottom: 80px;
color: #333;
}
.container form {
width: 280px;
text-align: center;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
form input {
width: 100%;
padding: 10px 5px;
margin: 10px 0;
border: 0;
border-bottom: 1px solid #999;
outline: none;
background: transparent;
}
::placeholder {
color: #777;
}
.btn-box {
width: 100%;
margin: 30px auto 30px auto;
text-align: center;
}
<div class="container">
<form class="form1">
<h2>Let's Start Building!</h2>
<input type="email" placeholder="E-mail" required>
<div class="btn-box">
<button class="BN" type="button">Next</button>
</div>
</form>
</div>
I can probably safely assume the reason why OP (aka Original Poster) won't use a <span> is because <input> has width: 100%. Whenever an display: inline (ie <span>) or inline-block proceeds an element that has width: 100%, that element is forced to occupy the space underneath the preceding element of width: 100%.
Simply decrease the width of the <input> and use a <span>
Demo A is exactly like OP's demo with the exception of the <input> having width: 90% and a <span class='asterisk'>*</span> proceeding it.
Demo B and Demo C are improved versions that:
uses semantic elements like <fieldset> and <legend>.
has some ineffective styles removed.
has the <div class="btn-box"> removed.
has altered margins, padding, text-align, and font-size that are ascetically better IMO.
has the property type='button' removed. See <button> in a <form> section below.
In addition Demo B uses the following to display an asterisk:
A <label> instead of a <span> for semantics's sake.
In addition Demo C uses the following to display an asterisk:
The CSS property ::after is assigned to the <fieldset> element instead of actually using an extra element like a <label> or <span> used in the previous demos.
Note: In all demos a special character was used for the actual asterisk called "combining asterisk above". This character appears at the top of the line much like a super-scripted character.
Also Note: The font-sizes are absolute values (px😬) which I would not normally use but the OP's demo is not responsive.
<button> in a <form>
A <button> within a <form> has inherit behavior when the user clicks it, the <form> will validate according to whatever applicable instructions are set within the HTML or JavaScript then if everything is proper it submits the data. If a <button> has type="button", that <button> doesn't do anything without JavaScript which means the HTML property required is limited to validating user input by showing a message when <input> is hovered on.
In Demo B and Demo C the <button> does not have type="button". Enter something that is not an email address and compare the behavior to Demo A. When a valid e-mail address is entered in Demo B or Demo C, the entered data disappears which means it was submitted (of course it doesn't have any JavaScript so it just submits to nowhere).
Demo A
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
height: auto;
margin: 8% auto;
background: #fff;
border-radius: 15px;
position: relative;
padding: 90px 0;
overflow: auto;
}
h2 {
text-align: center;
margin-bottom: 80px;
color: #333;
}
.container form {
width: 280px;
text-align: center;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
form input {
width: 90%;
padding: 10px 5px;
margin: 10px 0;
border: 0;
border-bottom: 1px solid #999;
outline: none;
background: transparent;
}
.asterisk {
font-size: 3ch;
color: red;
}
::placeholder {
color: #777;
}
.btn-box {
width: 100%;
margin: 30px auto 30px auto;
text-align: center;
}
<div class="container">
<form class="form1">
<h2>Let's Start Building!</h2>
<input type="email" placeholder="E-mail" required>
<span class='asterisk'>⃰</span>
<div class="btn-box">
<button class="BN" type="button">Next</button>
</div>
</form>
</div>
Demo B
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
padding: 90px 0;
margin: 8% auto;
background: #fff;
border-radius: 15px;
}
form {
width: 280px;
margin: 0 auto;
text-align: center;
}
form * {
font-size: 18px;
}
fieldset {
width: 100%;
border: 0;
}
.asterisk {
font-size: 3ch;
color: red;
cursor: help;
}
legend {
font-size: 24px;
font-weight: bold;
margin: 0 auto 20px auto;
color: #333;
}
input {
width: 90%;
padding: 10px 5px;
border: 0;
border-bottom: 1px solid #999;
outline: none;
text-align: center;
}
::placeholder {
text-align: center;
opacity: 0.3;
}
.next {
margin-top: 30px;
padding: 3px 15px;
border-radius: 6px;
cursor: pointer;
}
<section class="container">
<form>
<fieldset>
<legend>Let's Start Building!</legend>
<input type="email" placeholder="E-mail" required>
<label class='asterisk' title=' E-mail is required '>*</label>
</fieldset>
<button class="next">Next</button>
</form>
</section>
Demo C
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
padding: 90px 0;
margin: 8% auto;
background: #fff;
border-radius: 15px;
}
form {
width: 280px;
margin: 0 auto;
text-align: center;
}
form * {
font-size: 18px;
}
fieldset {
width: 100%;
border: 0;
}
.required::after {
content: '*';
font-size: 22px;
color: red;
}
legend {
font-size: 24px;
font-weight: bold;
margin: 0 auto 20px auto;
color: #333;
}
input {
width: 90%;
padding: 10px 5px;
border: 0;
border-bottom: 1px solid #999;
outline: none;
text-align: center;
}
::placeholder {
text-align: center;
opacity: 0.3;
}
.next {
margin-top: 30px;
padding: 3px 15px;
border-radius: 6px;
cursor: pointer;
}
<section class="container">
<form>
<fieldset class='required'>
<legend>Let's Start Building!</legend>
<input type="email" placeholder="E-mail" required>
</fieldset>
<button class="next">Next</button>
</form>
</section>
If it is possible for you to add to your HTML, a label associated with the input would be helpful, see for example MDN
Associating a with an element offers some major advantages:
The label text is not only visually associated with its corresponding
text input; it is programmatically associated with it too. This means
that, for example, a screen reader will read out the label when the
user is focused on the form input, making it easier for an assistive
technology user to understand what data should be entered. You can
click the associated label to focus/activate the input, as well as the
input itself. This increased hit area provides an advantage to anyone
trying to activate the input, including those using a touch-screen
device.
It remains after the placeholder has disappeared so the user is reminded what is needed, and you can format it. For example:
* {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
}
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url(/assets/1.png);
background-position: center;
background-size: cover;
}
.container {
width: 80%;
max-width: 700px;
min-height: 520px;
height: auto;
margin: 8% auto;
background: #fff;
border-radius: 15px;
position: relative;
padding: 90px 0;
overflow: auto;
}
h2 {
text-align: center;
margin-bottom: 80px;
color: #333;
}
.container form {
width: 280px;
text-align: center;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
form input {
width: 100%;
padding: 10px 5px;
margin: 10px 0;
border: 0;
border-bottom: 1px solid #999;
outline: none;
background: transparent;
}
label[for="email"]::after {
content: ' (required)';
color: red;
}
input[required] {
border: solid red;
}
::placeholder {
color: #777;
}
.btn-box {
width: 100%;
margin: 30px auto 30px auto;
text-align: center;
}
<div class="container">
<form class="form1">
<h2>Let's Start Building!</h2>
<label for="email">Please type in your email address</label>
<input id="email" type="email" placeholder="E-mail" required>
<div class="btn-box">
<button class="BN" type="button">Next</button>
</div>
</form>
</div>

fix position in a div css

I'm a new to css and i really can't fix all as i want...
How can i align vertical the h1 to the start of user form?
but most important problem for me is that i can't center good the check and the link, i want it one below the other and centered in the div.
I'm not sure if i have positioned good the div but i want it centred but not too low on the page.
thanks to everyone!
body {
text-align: left;
background-image: url("img/lemon.jpg");
color: #1b1b1b;
}
input[type=text],
input[type=password]{
width: 65%;
display: table;
margin: 0 auto;
padding: 12px 20px;
border: none;
border-bottom: 1px solid darkgray;
background-color: #e9e9e9;
box-sizing: border-box;
margin-bottom: 7px;
resize: vertical;
}
h1 {
font-size: x-large;
}
h2 {
font-size: x-large;
}
button {
background-color: #4CAF50;
color: white;
padding: 7px 20px;
width: 65%;
height: 20%;
display: table;
margin: 0 auto;
border: none;
cursor: pointer;
background: linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
background-color: #3d94f6;
border: 1px solid #337fed;
cursor: pointer;
color: #ffffff;
font-size: 17px;
text-decoration: none;
text-shadow: -1px 1px 1px #1570cd;
}
button:hover {
background: linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
background-color: #1e62d0;
}
button:active {
position: relative;
top: 1px;
}
.container {
width: 35%;
height: auto;
margin-right: auto;
margin-left: auto;
margin-top: 7%;
background-color: white;
box-shadow: 2px 2px 11px rgb(11, 11, 11);
-webkit-box-shadow: 2px 2px 11px rgb(11, 11, 11);
-moz-box-shadow: 2px 2px 11px rgb(11, 11, 11);
overflow: hidden;
}
#check {
display:block;
margin-top: 7px;
}
span.frgt {
margin-top: 7px;
display: block;
}
a {
text-decoration: none;
color: #1e62d0;
}
img {
width: 100%;
height: auto;
opacity: 0.4;
}
<!DOCTYPE html>
<head>
</head>
<body>
<div class="container">
<h1>Login</h1>
<input type="text" placeholder="Username" name="uname" required>
<input type="password" placeholder="password" name="psw" required>
<button type="submit">Login</button>
<hr>
<label id="check">
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
<span class="frgt">forgot password?</span>
</div>
</body>
</html>
If you set the h1 to the same width of the button and use "margin: 0 auto" to center it, this will make the h1 span the width of the button, and by default the text will be left aligned to the start of the button.
h1 {
font-size: x-large;
width: 65%;
margin: 0 auto;
}
I'm not too sure exactly what you want to do with the check section. If you use "text-align: center", this will center it, or use the same code as above to align it with the buttons.
you can use text-align: center; and vertical-align:top;
If your problem still exists, please explain more clearly what you want.
Use text-align: center; to center text within container.
To make it easier to align your elements, just wrap them into one div and adjust the div with CSS instead of dealing with each single element.
Here is an example of what you can do.
body {
text-align: left;
background-image: url("img/lemon.jpg");
color: #1b1b1b;
}
.form {
width: 75%;
margin: auto;
}
.form-bottom {
text-align: center;
}
input[type=text],
input[type=password] {
display: table;
margin: 0 auto;
width: 100%;
padding: 12px 20px;
border: none;
border-bottom: 1px solid darkgray;
background-color: #e9e9e9;
box-sizing: border-box;
margin-bottom: 7px;
resize: vertical;
}
h1 {
font-size: x-large;
}
h2 {
font-size: x-large;
}
button {
background-color: #4CAF50;
color: white;
padding: 7px 20px;
height: 20%;
width: 100%;
display: table;
margin: 0 auto;
border: none;
cursor: pointer;
background: linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
background-color: #3d94f6;
border: 1px solid #337fed;
cursor: pointer;
color: #ffffff;
font-size: 17px;
text-decoration: none;
text-shadow: -1px 1px 1px #1570cd;
}
button:hover {
background: linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
background-color: #1e62d0;
}
button:active {
position: relative;
top: 1px;
}
.container {
width: 35%;
height: auto;
margin-right: auto;
margin-left: auto;
margin-top: 7%;
background-color: white;
box-shadow: 2px 2px 11px rgb(11, 11, 11);
-webkit-box-shadow: 2px 2px 11px rgb(11, 11, 11);
-moz-box-shadow: 2px 2px 11px rgb(11, 11, 11);
overflow: hidden;
}
#check {
display: block;
margin-top: 7px;
}
span.frgt {
margin-top: 7px;
display: block;
}
a {
text-decoration: none;
color: #1e62d0;
}
img {
width: 100%;
height: auto;
opacity: 0.4;
}
<body>
<div class="container">
<div class="form">
<h1>Login</h1>
<input type="text" placeholder="Username" name="uname" required>
<input type="password" placeholder="password" name="psw" required>
<button type="submit">Login</button>
</div>
<hr>
<div class="form-bottom">
<label id="check">
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
<span class="frgt">forgot password?</span>
</div>
</div>
</body>

How would I keep this forms contents from leaving the frame?

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>

Why aren't all 100% of the DIV is used?

I have the following HTML code:
<div class="dispLoginSearch"> <!-- LOGIN AND SEARCH -->
<div class="loginBox">
<p>Log in to <span>My</span> <span>M</span> | Sign Up</p>
<div style="width: 100%; padding: 0; margin: 0; overflow: hidden; height: 38px;" class="brClear">
<input type="text" placeholder="Username" id="txtUsername" class="txtUsername styledTB floatLeft" />
<input type="password" placeholder="Password" id="pwPassword" class="txtPassword styledTB floatLeft" />
Login
</div>
Forgot login/password
</div>
</div>
CSS:
.dispLoginSearch
{
width: 40%;
height: 180px;
vertical-align: middle;
float: right;
padding-right: 3%;
background: #FFFFFF;
overflow: hidden;
text-align: center;
margin: 0 auto;
}
.loginBox {
margin-top: 3%;
border: 1px solid #d4d4d4;
display: block;
width: 100%;
font: 16px sans-serif;
padding: 0 0 0 15px;
border-radius: 5px;
-webkit-font-smoothing: antialiased;
text-align: left;
overflow: auto;
}
.loginBox p {
margin: 5px 0 0;
font-size: 20px;
line-height: 35px;
}
.txtUsername{
width: 38%;
margin-right: 2%;
height: 30px;
}
.txtPassword {
width: 38%;
margin-right: 2%;
height: 30px;
}
.floatLeft
{
float: left;
}
.logBtn
{
width: 10%;
height: 30px;
line-height: 30px;
}
.styledBtn
{
background: #d75813;
display: block;
box-shadow:
0px 5px #BC490A,
0px 8px 10px rgba(148, 148, 148, 0.5);
text-align: center;
vertical-align: middle;
}
.styledTB {
padding-left: 5px;
background: #E8E8E8;
opacity: 1;
border: none;
outline: none;
right: 35px;
box-shadow:
0px 5px #BBB,
0px 8px 10px rgba(148, 148, 148, 0.5);
}
If I keep the logBtn at 10% it stays in the same line but the letter gets cut off almost:
If I increase the percentage to 12%, instead of expanding on the same line to fill up the DIV, it goes to the next line:
For some reason I am not able to use the 100% of the width from the parent DIV. I used float: right on the forgot login/password link and that's how far it goes. For some reason the right side of the DIV is completely not accessible.
How do I resolve the issue?
The inline style will be removed when I have resolved the issue.
Your problem comes from the horizontal paddings you are adding onto the inputs. Those are added to the percentage width and percentage margin you have put on the inputs.
try using the box-sizing: border-box; property on the inputs so the paddings won't get added to the specified width and margins
Some explaination about box-sizing can be found here

Search bar icon styling

I have a search text field. How can i place another search icon in search textfield?
Like one in this Image:
I need this Magnifying Button in my Textfield ( Which will be click-able )
Here is my Search Field: http://jsfiddle.net/ULtH4/
Here is my Code :
HTML:
<input type="text" name="search_people" placeholder="Search for people..." class="search_container_textfield" size="30" value="" id="inputString" />
CSS:
.search_container {
background-color: #FFFFFF;
width: 500px;
border-radius:5px 5px 5px 5px;
border:solid 1px #DFDFDF;
padding:2px;
}
.search_container_textfield {
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
border-collapse: collapse;
border-radius: 5px 5px 5px 5px;
float: left;
font-size: 13px;
height: 23px;
padding: 6px 4px;
position: relative;
width: 496px;s
}
.search_container_text {
color:#006666; font-size:13px; font-weight:normal;vertical-align:top !important;
}
Here's a Fiddle
<div class="search_container">
<input type="text" name="search_people" placeholder="Search for people..." class="search_container_textfield" size="30" value="" id="inputString" />
</div>
.search_container_textfield {
border: 1px solid #ccc;
border-radius: 5px 5px 5px 5px;
float: left;
font-size: 13px;
height: 23px;
padding: 6px 4px;
position: relative;
width: 496px;
}
.search_container_textfield:focus {
outline: none;
box-shadow: 0 0 2px 1px #00aeff;
}
.search_container a {
background: url(http://www.extendcomm.com/wp-content/themes/extendcomm/images/icons/icon-search.png) center no-repeat;
background-size: 30px 30px; /* background-size added because original icon is 128x128px */
display: block;
position: relative;
width: 37px;
height: 35px;
float: right;
margin: -37px -6px 0 0;
padding-left: 3px;
border: 1px solid #ccc;
border-radius: 0 5px 5px 0;
}
.search_container a:hover {
background: #e8e8e8 url(http://www.extendcomm.com/wp-content/themes/extendcomm/images/icons/icon-search.png) center no-repeat;
background-size: 30px 30px; /* background-size added because original icon is 128x128px */
}
Final result
And if you want to search id's from search filed below is jQuery solution
$(function() {
$('.search_container a').hover(function() {
var id = $('.search_container_textfield').val();
$(this).attr('href', 'search_people.php?id='+id);
});
});
You can wrap a <span> around the input and then use span:after to content to it, position it absolute and align it to how you want.
Fiddle here All you need to do is change 'Search' for an icon.
Here is another method I done, which supports 'fontawesome-' fonts.
This link here has an icon (Which is clickable too)