Input box and checkbox’s heights are different - html

I made a login box using Bootstrap 3.0.3. On the second line, the password input box’s and check box”s (labelled Auth) heights are different. On mobile, the difference is even more noticeable.
How can I make their heights match?
Bootply
<form name="fhead" method="post" onsubmit="return fhead_submit(this);" autocomplete="off" role="form" class="form-inline">
<div id="outlogin_box" name="outlogin_box">
<input type="hidden" name="url" value="<?=$outlogin_url?>">
<input type="text" class="form-control input-sm" name="mb_id" maxlength="20" itemname="id" placeholder="login id">
<div class="input-group"><!-- needs height alignment -->
<input type="password" class="form-control input-sm" name="mb_password" id="outlogin_mb_password" maxlength="20" itemname="password" placeholder="password">
<span class="input-group-addon">
<div class="checkbox">
<label>
<input type="checkbox" name="auto_login" title="Remember me" value="1" onclick="if (this.checked) { if (confirm('자동로그인을 사용하시면 다음부터 회원아이디와 패스워드를 입력하실 필요가 없습니다.\n\n\공공장소에서는 개인정보가 유출될 수 있으니 사용을 자제하여 주십시오.\n\n자동로그인을 사용하시겠습니까?')) { this.checked = true; } else { this.checked = false; } }">
Auto
</label>
</div>
</span>
</div>
<div class="input-group">
<button type="submit" class="btn btn-success btn-sm btn-group-justified" >Login</button>
</div>
<div class="input-group">
<div class="btn-group btn-group-justified">
<a class="btn btn-default btn-sm" title="Register" href="<?=$g4[bbs_path]?>/register.php">Register</a>
<a class="btn btn-default btn-sm" title="회원 id, password 찾기" href="javascript:win_password_lost();">아이디찾기</a>
</div>
</div>
</div>
</form>

Change
<input class="form-control input-sm" name="mb_password" ...
to
<input class="form-control" name="mb_password" ...
http://www.bootply.com/98872
You have modified the height of the input by adding a class "input-sm".

Try this very simple:
input[type=checkbox], input[type=radio] {
vertical-align: middle;
position: relative;
bottom: 1px;
}
input[type=radio] {
bottom: 2px;
}

You can set fixed width and height values for HTML textboxes/checkboxes in CSS by doing the following...
input[type="text"] {
width: 10%;
height:3%;
}
input[type="password"] {
width: 10%;
height:3%;
}
input[type="checkbox"] {
height:2%;
}
You can also set them using px instead of percentages.
Hopefully setting a fixed height and width should resolve your conflicting size problems.

Try overriding bootstrap CSS with this:
.input-group-addon .checkbox {
margin: 8px 5px 0 !important;
}
.input-group-addon {
padding:0 !important;
}

change your css of checkbox class display which is display : inline-block to display: inline and the try it
.form-inline .radio,.form-inline .checkbox{display:inline-block;padding-left:0;margin-top:0;margin-bottom:0}
to
.form-inline .radio,.form-inline .checkbox{display:inline;padding-left:0;margin-top:0;margin-bottom:0}
in bootstrap.min.css

Related

Inline form input with label over input centered

I have a form with long labels over each input and I want the input centered underneath each label but I also need the inputs to stay inline. It should look like this below but the inputs should be centered under each long label.
Here is what I have but I am having trouble making the inputs center under the labels.
.question-container {
width: 1000px;
margin: 0 auto;
}
#questions {
margin: 5px 30px;
display: inline-block
}
<div class="form-inline">
<span id="questions">
<label>How much will your house cost?</label>
<input class="form-control" type="text" placeholder="input">
</span>
<span id="questions">
<label>What is the most you can pay monthly?</label>
<input class="form-control" type="text" placeholder="input">
</span>
<span id="questions">
<label>What is your Current Monthly Rent?</label>
<input class="form-control" type="text" placeholder="input">
</span>
</div>
<div id='centered'>
<button type="submit" class="btn btn-primary mb-2">Submit</button>
</div>
Any help would be greatly appreciated!
Got it!
Simply had to add text-align:center; to the span
#questions {
margin:5px 30px;
display:inline-block;
text-align:center;
}

CSS- Changing the width of a search box

I'd been trying to change the width of the search box in name="size" of my HTML template but can't do it even when I tried width:.
html:
<form class="form" method = "POST" >
<h1>Soccer Shoes Finder</h1>
<div class="line-separator"></div>
<div class="container-fluid form-inline">
<input class="form-control" name = "name" type="text" placeholder="Name"/>
<input class="form-control" name = "size" type="text" placeholder="Size"/>
<button class="form-control fa fa-search" aria-hidden="true"></button>
</div>
</form>
css of the element:
input[name="size"]{
width: 50%;
}
Here's a codepen for better context:
http://codepen.io/tadm123/pen/ZLVWpd
I recommend using this method.
<form class="form" method="POST">
<h1 class="text-center">Soccer Shoes Finder</h1>
<div class="line-separator"></div>
<div class="container ">
<div class="row">
<div class="col-md-4">
<input class="form-control" name="name" type="text" placeholder="Name" />
</div>
<div class="col-md-7">
<input class="form-control" name="size" type="text" placeholder="Size" /></div>
<div class="col-md-1">
<button class="form-control " aria-hidden="true"><i class="fa fa-search"></i></button></div>
</div>
</div>
</form>
Updated Codepen:
http://codepen.io/hunzaboy/pen/aJJpMK
It's getting overwritten by the bootstrap defaults. Specifically:
.form-inline .form-control {
display: inline-block;
width: auto;
vertical-align: middle;
}
You need to adjust your selector to fix the cascade:
.form-inline input.form-control[name="size"]{
width: 50%;
}
did you try size attribute?
<input type="text" size="15"/>
The input elements use by default display: inline;, you cannot define a width in elements who using that display, if your change the display to display: inline-block; you will can change the width of your element.
input[name="size"]{
width: 50%;
display: inline-block; /* <--- Here the change */
}
Suppose you have a class-name (defined in HTML) of inputText (name).
Adding these lines will help (clean-way/simple).
.inputText{
//...
width:200px;
transition: width .4s ease-in;
}
.inputText:hover, .inputText:focus{
width:400px;
}

Custom input style with a icon inside and button in the right

I am trying to get a custom input style have a glyph icon inside and have a button on the right that says go.
Here is my js fiddle with it. jsfiddle
<div class="form-group">
<div class="icon-addon addon-sm">
<input type="text" placeholder="Search All Orders" class="form-control" id="Order Search">
<label for="email" class="glyphicon glyphicon-search" rel="tooltip" title="email"></label>
</div>
</div>
The problem i am having is when i try to add the button on the right it makes the icon disappear when the input is clicked.
Using your fiddle I simply added an absolutely positioned button into your search box. Perhaps this is what you were looking for?
Added button in HTML:
<input type="text" placeholder="Search All Orders" class="form-control" id="Order Search">
<label for="email" class="glyphicon glyphicon-search" rel="tooltip" title="email"></label>
<button class="button-go">go</button>
Button's CSS:
.button-go {
position: absolute;
right: 0;
top: 0;
height: 30px;
}
https://jsfiddle.net/t6295xrd/
Here is a Demo for what i understood from you i just add the button to your fiddle and add this css to position it on right.
#Order_Search {
padding-right:20px;
}
.go-btn {
position: absolute;
right: 3px;
margin-left: -2.5px;
top: 2px
}
and this is the html
<div class="form-group">
<div class="icon-addon addon-sm">
<input type="text" placeholder="Search All Orders" class="form-control" id="Order_Search">
<label for="email" class="glyphicon glyphicon-search" rel="tooltip" title="email"></label>
<button class="go-btn"> Go </button>
</div>

Bootstrap 3 inline layout not working

I'm using the following markup with Bootstrap 3.
<div class="row" style="margin-bottom: 12px">
<form class="form-inline">
<div class="form-group">
<label for="startDate">Start Date:</label>
<input type="date" class="form-control" id="startDate" value="10/29/1961" placeholder="Start Date">
</div>
<div class="form-group">
<label for="endDate">End Date:</label>
<input type="date" class="form-control" id="endDate" value="11/2/1972" placeholder="End Date">
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
According to all the examples I could find, this should put everything inline. However, for me, the labels appear over the textboxes rather than to the side of them.
I tried not enclosing the markup with <div class="row">. I also tried using <input type="text"> instead of <input type="date"> but none of that made any difference. I've triple checked the markup. Can anyone see what I'm doing wrong?
If I force the containers to be wider, then it appears closer to what I expect. But none of the examples I've seen do this. And I'd prefer to not specify a fixed width.
This is due to the version of Bootstrap 3 that you are using. The form-control class changed to width: auto within inline forms in v3.1.0. So versions v3.0.0, v3.0.1, v3.0.2 and v3.0.3 should all display the problem you are seeing. After the v3.1.0 release it should no longer be a problem.
From the release notes:
#11836: Along with the form validation update, we reset some key form and icon styles:
All .form-controls within inline forms are set to width: auto; to prevent stacking of .form-label within a .form-group.
Removes all select.form-control settings since those are now inherited by the above change
Removes the width: 1em; from the Glyphicons because it was virtually impossible to override.
Any version between 3.1.0 and the current 3.3.6 should work as you expect.
That being said, if you cannot upgrade you can still implement this on your own. See 3rd Snippet.
Example of the issue with v3.0.0
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<form class="form-inline">
<div class="form-group">
<label for="startDate">Start Date:</label>
<input type="date" class="form-control" id="startDate" value="10/29/1961" placeholder="Start Date">
</div>
<div class="form-group">
<label for="endDate">End Date:</label>
<input type="date" class="form-control" id="endDate" value="11/2/1972" placeholder="End Date">
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
Example of expected behavior with v3.1.0
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<form class="form-inline">
<div class="form-group">
<label for="startDate">Start Date:</label>
<input type="date" class="form-control" id="startDate" value="10/29/1961" placeholder="Start Date">
</div>
<div class="form-group">
<label for="endDate">End Date:</label>
<input type="date" class="form-control" id="endDate" value="11/2/1972" placeholder="End Date">
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
Example using v3.0.0 with fix:
#media (min-width: 768px) {
.form-inline .form-control {
width: auto;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<form class="form-inline">
<div class="form-group">
<label for="startDate">Start Date:</label>
<input type="date" class="form-control" id="startDate" value="10/29/1961" placeholder="Start Date">
</div>
<div class="form-group">
<label for="endDate">End Date:</label>
<input type="date" class="form-control" id="endDate" value="11/2/1972" placeholder="End Date">
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>
</div>
All current form-inline css just in case:
#media (min-width: 768px) {
.form-inline .form-group {
display: inline-block;
margin-bottom: 0;
vertical-align: middle
}
.form-inline .form-control {
display: inline-block;
width: auto;
vertical-align: middle
}
.form-inline .form-control-static {
display: inline-block
}
.form-inline .input-group {
display: inline-table;
vertical-align: middle
}
.form-inline .input-group .form-control,
.form-inline .input-group .input-group-addon,
.form-inline .input-group .input-group-btn {
width: auto
}
.form-inline .input-group>.form-control {
width: 100%
}
.form-inline .control-label {
margin-bottom: 0;
vertical-align: middle
}
.form-inline .checkbox,
.form-inline .radio {
display: inline-block;
margin-top: 0;
margin-bottom: 0;
vertical-align: middle
}
.form-inline .checkbox label,
.form-inline .radio label {
padding-left: 0
}
.form-inline .checkbox input[type=checkbox],
.form-inline .radio input[type=radio] {
position: relative;
margin-left: 0
}
.form-inline .has-feedback .form-control-feedback {
top: 0
}
}
your code is fine ,, but note that
Controls only appear inline in viewports that are at least 768px wide to account for narrow viewports on mobile devices.
here is my screenshot for your code
I've run into this issue in the past when I was using mvc to add my textboxes. I solved this issue by overriding the form-group class or by using an inline style on the div to set display: flex; This would force it into one line.
<div class="form-group" style="display:flex;">
<label for="startDate">Start Date:</label>
<input type="date" class="form-control" id="startDate" value="10/29/1961" placeholder="Start Date">
</div>

Form isn't wrapping in the correct class

I am writing some code that hides and displays a different form depending on whether the user wants to login or register. However for some reason my form isn't displaying in the html in between the <form class="login-inputs"> , its doesn't even appear in the HTML doc. Can anyone see why?
<div class="col-md-3">
<button type="button" id="login" class="btn btn-default login hidden">Login</button>
<button type="button" id="register" class="btn btn-default register">Register</button>
<form class="login-inputs hidden">
<h3>Login</h3>
<div class="form-group">
<label for="inputEmail">Email</label>
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>
Remove the hidden class.
media screen element "on" and "off" class:
/* For Phone device */
.visible-xs{
display: block !important;
}
.hidden-xs{
display: none !important;
}
/* For Phone device End */
#media (min-width: 768px){
.visible-sm{
display: block !important;
}
.hidden-sm{
display: none !important;
}
}
#media (min-width: 992px){
.visible-md{
display: block !important;
}
.hidden-md{
display: none !important;
}
}
#media (min-width: 1200px){
.visible-lg{
display: block !important;
}
.hidden-lg{
display: none !important;
}
}
Just use the class. This CSS already have bootstrap 3.