How to fit the text inputs in div using Bootstrap? - html

I am creating a form using Bootstrap and the text input widths are too long. I tried to set the width = 35% of class form-control in bootstrap.css and it looks ok, but when I resized the screen it overlapped the other <div>. As of now I changed it back to 100%. And it is too long and it overlap the other <div>.
Here is my code:
<div class="col-sm-10">
<div class="col-sm-12">
<div class="col-sm-6">
<h4>LOGIN</h4>
<div class="panel panel-default" style="border: solid 2px black">
<div class="panel-body" style="min-height: 456px">
<div class="row">
<div class="container">
<div class="col-sm-12">
<form role="form">
<div class="form-group">
<h4>REGISTER</h4>
<p>Please login to take advantage of promotions and benefits reserved to registered users.</p>
</div>
<div class="form-group" style="margin-top: 35px">
<h5>EMAIL ADDRESS* </h5>
<input type="text" class="form-control" />
</div>
<div class="form-group">
<h5>PASSWORD* </h5>
<input type="password" class="form-control" />
</div>
<div class="form-group">
<span><input type="checkbox" style="margin-top: 20px" /></span><span> Remember me next time</span>
</div>
<div class="form-group">
<span>
<button type="button" class="btn btn-default" onclick="location.href='register.html'" >REGISTER NOW</button>
</span>
<span>
Forgot your password?
</span>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<h5> </h5>
<div class="panel panel-default" style="border: solid 2px black">
<div class="panel-body" style="min-height: 456px">
<h5>NEW USER</h5>
<div class="register-notify">
<p>Register now and enjoy the benefits of My Account. Only registered users can:</p>
<p>- Access to your personal information through My Account</p>
<p>- Use the Wish List to save their favorite products</p>
<p>- Complete the checkout process more quickly</p>
</div>
<div style="margin-top: 150px">
<input type="button" value="REGISTER NOW" class="register-button" onclick="location.href='register.html'" />
</div>
</div>
</div>
</div>
</div>

Change the class of the div tag to col-sm-6. This should do the trick.
<div class="container">
<div class="col-sm-6"> <!--The div tag before the form-->
<form role="form">
Check out the demo here.

Related

Structure position html

my english is so bad. Bear with me.
I cant move de position of a button submit. All styles have no effect.
This is the code (html, bootstrap 3):
<body>
<div class="row">
<div class="col-sm-12">
<!-- LOGO -->
<div class="col-sm-3">
<img src="../web/assets/img/logo-biblioteca.png" alt="Biblioteca Virtual">
</div>
<!-- BUSCADOR -->
<div class="col-sm-8">
<div class="well" >
<form class="form-group" action="">
<div class="col-sm-1" style="margin-top: 0.5%">
<label for="titulo"><b> Título </b></label>
</div>
<div class="col-sm-11">
<input class="form-control" type="text" placeholder="Ingrese un titulo" name="titulo" required>
</div>
<div class="col-sm-1" style="margin-top: 2.5%">
<label for="autor"><b> Autor </b></label>
</div>
<div class="col-sm-11" style="margin-top: 2%">
<input class="form-control" type="text" placeholder="Ingrese un autor" name="autor" required>
</div>
<div class="text-right row">
<button class="btn btn-info btn-md" type="submit">Buscar</button>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
I cant move the button Buscar.
Please tell us more information, but you can also attempt to try this when using inline styling: !important;
Example..
<div id="placement" class="text-left"> <!-- text-center, text-right works too. -->
<button here>button</button>
</div>
This should work with Bootstrap, if you have it installed properly.
You could also attempt to put a float:left/right on the button itself and see what happens.

Why does the input element not fill the contents of the div?

Here is my existing view.
I do not understand why the textbox for "bbbbbbb" does not take the same width as column "aaaaa".
I set the border on the div and it clearly illustrates the width.
Why does the input element not fill the contents of the div?
<div class="container">
<div class="row" style="padding-top:10px;">
<div class="col-sm-2">
<label for="mtc">aaaaaa</label>
</div>
<div class="col-sm-10">
#(Html.Kendo().MultiSelect()
.Name("mtc")
.DataValueField("aaa")
.DataTextField("bbb")
.Placeholder("Select Map Type Codes...")
.AutoBind(false)
.DataSource(src =>
{
src.Read("Action", "Controller");
})
)
</div>
</div>
<div class="row" style="padding-top:10px;">
<div class="col-sm-2">
<label for="bb">bbbbbbb</label>
</div>
<div class="col-sm-10" style="border:solid">
<input type="text" style="width:100%;" class="k-textbox" id="bb" />
</div>
</div>
<div class="row" style="padding-top:10px;">
<div class="col-sm-2"></div>
<div class="col-sm-10">
<input type="submit" value="Submit" id="btnSubmit" class="btn btn-primary" />
</div>
</div>
</div>

Unable to position well to center

I am trying to position a well to the center of the page. There are similiar questions on SO, but the code is somewhat different to mine. My HTML is given below:
<div class="container">
<div class="row">
<div class="well col-sm-4" align="center">
<div class="text-center">
<p><h2>Login</h2></p>
</div>
<hr>
<form role="form">
<div class="form-group text-center">
<label for="username">Username</label>
<input type="text" class="form-control" id="username">
</div>
<div class="form-group text-center">
<label for="password">Password</label>
<input type="password" class="form-control" id="password">
</div>
<hr>
<div class="text-center">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="button" class="btn btn-warning">Forgot password</button>
</div>
<hr>
<div class="text-center">
<p>Don't have an account yet? <a>Create one now</a></p>
</div>
</form>
</div>
</div>
</div>
I tried putting the well div inside another div with col-md-12 and other values, but the well did not get centered. Does anyone know how I could center the well in the page?
You could try offsetting columns
Give your columns the class col-sm-offset-4
Like so: <div class="well col-sm-offset-4 col-sm-4">
Example: http://jsfiddle.net/u48v34p7/
<div class="container">
<div class="row">
<div class="col-sm-4 well col-sm-offset-4" align="center">
<div class="text-center">
<p><h2>Login</h2></p>
</div>
<hr>
<form role="form">
<div class="form-group text-center">
<label for="username">Username</label>
<input type="text" class="form-control" id="username">
</div>
<div class="form-group text-center">
<label for="password">Password</label>
<input type="password" class="form-control" id="password">
</div>
<hr>
<div class="text-center">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="button" class="btn btn-warning">Forgot password</button>
</div>
<hr>
<div class="text-center">
<p>Don't have an account yet? <a>Create one now</a></p>
</div>
</form>
</div>
</div>
</div>
Just replace your code here:
<div class="well col-sm-4" align="center">
With this (you can also isolate the style in a CSS class):
<div class="well col-sm-4" style="margin:auto; float:none;">
You could put two dummy divs to make your well centered. I have noticed that you only have one col-sm-4
Try this:
<div class = "col-sm-4"></div>
<div class = "well col-sm-4">
<!-- your content here -->
</div>
<div class = "col-sm-4"></div>
In that way you can have your well centered.
You can also do this
<div class = "well col-md-6 col-md-offset-3">
<!-- content here -->
</div>
To make your well centered on desktop view 1280px and above.

how do i control width of input with bootstrap

i am trying to control my width's for my input but i am having some trouble. Here is my mark up
<section class="bg-lb pt40 pb40 btborder">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="bg-white ">
<div class="pt40 pb40">
<a class="btn btn-default hvr-fade">Login</a>
<span id="cricle"><b>OR</b></span>
<a class="btn btn-default hvr-fade">Register</a>
</div>
<form>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="ion-person"></span></div>
<input type="text" id="" class="form-control" placeholder="Username">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="ion-android-lock"></span></div>
<input type="password" id="" class="form-control" placeholder="Password">
</div>
</div>
<a class="btn btn-default hvr-fade"><b>LOGIN</b></a>
</form>
</div>
</div>
</div>
</div>
</section>
im just simply trying to reduce the width of the input and center the form,
live preview here
http://plnkr.co/edit/RN6tPNCynK2lEdTeWmFQ?p=preview
If you want to continue using the grid system you can change the way your col-'s are setup.
Change:
<div class="row">
<div class="col-sm-12">
<div class="bg-white">
<form>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="ion-person"></span>
</div>
<input type="text" id="" class="form-control" placeholder="Username">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="ion-android-lock"></span>
</div>
<input type="password" id="" class="form-control" placeholder="Password">
</div>
</div>
</form>
</div>
</div>
</div>
To:
<div class="row">
<div class="bg-white">
<form>
<div class="col-md-6 col-md-offset-3">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="ion-person"></span>
</div>
<input type="text" id="" class="form-control" placeholder="Username">
</div>
</div>
</div>
<div class="col-md-6 col-md-offset-3">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><span class="ion-android-lock"></span>
</div>
<input type="password" id="" class="form-control" placeholder="Password">
</div>
</div>
</div>
</form>
</div>
</div>
The main difference is that <div class="col-md-6 col-md-offset-3"> is now specifically wrapping the <div class="form-group">. Where the col-md-offset-3 is what will be centering your form.
Or to go a bit further, create a new <div class="row"> for each <div class="form-group"> instead of embedding all columns into one row.
The bootstrap way is to reduce the width of the column the form is in. With 3 columns you can center the form:
<div class="col-sm-3"></div>
<div class="col-sm-6">form comes here</div>
<div class="col-sm-3"></div>
http://plnkr.co/edit/DSroqJsfQBTuwBUgo3ps?p=preview
Just override bootstrap .css in a particular place. Try this for eg:
put it inside the css:
input.form-control{
max-width: 100px;
}
input.form-control will override every input with class set to : form-control
Or you can shrink the entire container class
.container{
max-width: 250px;
}
Test here : http://plnkr.co/edit/kR69nCvsDCp9AlQqZztY?p=preview

How can I add a Button to the end of this form field and retain the Bootstrap styling

I'm trying to add a search glyph to a button at the end of this centered search bar.
Below is the style I want:
<div class="row">
<div class="col-md-12">
<div class="jumbotron text-center">
<h1>Jumbotron with form</h1>
<form>
<div class="col-md-6 col-md-offset-3">
<div class="input-group input-group-lg">
<input type="text" class="form-control" placeholder="Username">
<span class="input-group-addon">Search</span>
</div>
</div>
</form>
<br><br>
</div>
</div>
</div>
But I want to to have a button a - something like:
<span class="glyphicon glyphicon-search"></span></button>
instead of the
<span class="input-group-addon">Search</span>
but when I do this the button moves onto the next line and throws off my styling.
Using Bootstraps form-inline class and form structure will resolve your issue.
<div class="row">
<div class="col-md-12">
<div class="jumbotron text-center col-md-6 col-md-offset-3">
<h1>Jumbotron with form</h1>
<form class="form-inline" role="form">
<div class="form-group form-group-lg">
<input type="text" class="form-control" placeholder="Username">
</div>
<div class="form-group form-group-lg">
<button type="button" class="btn btn-default btn-lg pull-left">
<span class="glyphicon glyphicon-search"></span> Search
</button>
</div>
</form>
<br><br>
</div>
</div>
</div>
Try this:
DEMO
<div class="row">
<div class="col-md-12">
<div class="jumbotron text-center">
<h1>Jumbotron with form</h1>
<form>
<div class="col-md-6 col-md-offset-3">
<div class="input-group input-group-lg">
<input type="text" class="form-control" placeholder="Username">
<span style="padding:5px 0px 5px 0px !important" class="input-group-addon"><button class="btn"><span class="glyphicon glyphicon-search"></span> Search</button></span>
</div>
</div>
</form>
<br>
<br>
</div>
</div>
</div>