Though I made the submit button and the input text exactly:
width:60%
But when I run the app, they don't have the same width:
.loginClass {
width: 40%;
height: 40%;
margin: auto auto;
}
.loginClass ul li {
list-style: none;
}
.loginClass ul li input {
width: 60%;
}
<form class="loginClass">
<ul>
<li>
<input placeholder="Username" name="username" type="text" value="">
</li>
<li>
<input placeholder="Username" name="username" type="text" value="">
</li>
<li>
<input type="submit" value="Login">
</li>
</ul>
</form>
Could you please explain and help?
The value attribute can be used to change the text of the form submit button. Use value attribute within <input> of type="submit" to rename the button.
The attribute that changes the name shown on the Submit Button is the Value attribute. You can change the text that appears on the Submit Button by setting the Value attribute to the desired name you want.
The key is to use the box-sizing: border-box property so when you specify the width that includes the border and padding. See excellent explanation here. Then the browser can't stuff it up. Code is below, have also set the height of the boxes to the same size and indented the text inside the box so it lines up.
That's because both border-box attributes are different by default..
Use box-sizing: content-box
on the button, or box-sizing: border-box
on the Input Elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With