Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS submit button and input text don't have the same width

Tags:

html

css

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?

like image 962
user2208349 Avatar asked Jun 24 '14 14:06

user2208349


People also ask

How do I change the submit button text in CSS?

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.

How do I change the input submit button text?

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.

How do you make all text boxes the same size in HTML?

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.


1 Answers

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.

like image 110
Tarulia Avatar answered Oct 16 '22 10:10

Tarulia