Placing DIV on the right side of form - html

I have a div in a form and i want to place the div on the right side of the form and the div must be fixed on the right side with the button. I don't know if this can be done but how can i get this done.
HTML
<form class="form-horizontal" method="post">
<div class="form-group">
<label for="name" class="col-lg-1 control-label"> Name</label>
<div class="col-lg-6">
<input type="text" class="typeahead form-control" id="name" placeholder="Name" name="name" required>
</div>
</div>
<!--i want to move this div to the right side of the form and fixed-->
<div style="background-color:white" class="move-right" id="move-right">
<legend style="text-align: center" >Heading <span></span></legend>
</div>
<div>
<button type="submit" class="btn ">Save</button>
</div>
</form>
</div>

If the content of the right should not overlap the other content you need:
.move-right { float:right; } in the css.
And reorder the html code to place the floating element above the others:
<form class="form-horizontal" method="post">
<div style="background-color:white" class="move-right" id="move-
right">
<legend style="text-align: center" >Heading <span></span></le zgend>
</div>
<div class="form-group">
<label for="name" class="col-lg-1 control-label"> Name</label>
<div class="col-lg-6">
<input type="text" class="typeahead form-control" id="name"
placeholder="Name" name="name" required>
</div>
</div>
<div>
<button type="submit" class="btn ">Save</button>
</div>
</form>
otherwise, if the contents can overlap:
use the .move-right { position: absolute; right: 0px; } and .form-horizontal { position: relative; } css code.

Related

Bootstrap: How can I put a line break between the textarea and button?

This is the bootstrap page
<div id="cover-caption">
<div id="container" class="container-fluid">
<div class="row d-flex">
<div class="col-lg-10 offset-sm-1 text-center"><br>
<h1 class ="font-weight-bold">Classes</h1>
<div class="info-form">
<form action="" class="form-inline justify-content-center">
<div class="form-group">
<input type="text" class="form-control" placeholder="Class Name">
</div><br>
<div class="form-group">
<input type="text" class="form-control" placeholder="Title">
</div><br>
<div class="form-group">
<textarea type="text" class="form-control" placeholder="Notes"></textarea>
</div>
<button type="submit" class="btn btn-warning">Submit</button>
</form>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
Here is my CSS:
#cover {
background: #222 url('') center center no-repeat;
background-size: cover;
height: 100%;
text-align: center;
display: flex;
align-items: center;
}
#cover-caption {
width: 100%;
}
I want to put a line break between the textarea and button, and <br> doesn't work. Can someone explain why and help me fix it
Are you looking for <hr> ? or simply <br><br> ?
Or you could put style="padding-top: 10px;" on the button...
Have a great day.
EDIT:
removed form-inline class from form tag, replaced with span (you'll need to fix the centering):
<div id="cover-caption">
<div id="container" class="container-fluid">
<div class="row d-flex">
<div class="col-lg-10 offset-sm-1 text-center">
<br>
<h1 class="font-weight-bold">Classes</h1>
<div class="info-form">
<form action="">
<span class="form-inline justify-content-center">
<div class="form-group">
<input type="text" class="form-control" placeholder="Class Name">
</div>
<br>
<div class="form-group">
<input type="text" class="form-control" placeholder="Title">
</div>
<br>
<div class="form-group">
<textarea type="text" class="form-control" placeholder="Notes"></textarea>
</div>
</span>
<button type="submit" class="btn btn-warning">Submit</button>
</form>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
I finally understand your problem.
You are letting the bootstrap CSS form to override your button. You dun need to change anything instead just put the button outside the form.
<form action="" class="form-inline justify-content-center">
<div class="form-group">
<input type="text" class="form-control" placeholder="Class Name">
</div><br>
<div class="form-group">
<input type="text" class="form-control" placeholder="Title">
</div><br>
<div class="form-group">
<textarea type="text" class="form-control" placeholder="Notes"></textarea>
</div>
</form>
<button type="submit" class="btn btn-warning">Submit</button>

make a modal with form inputs on same line, length, and white space? (pic example provided)

Been trying for a few hours meow, (really need to get better at html) but all I want is essentially 3 inputs on a modal, with form-control would be nice cause I like the appearance but doesn't have to be at this point, on a bootstrap modal for payment.
Here is what I'm trying to get
I know right, you think I'd be able to get this
<div class="modal-body text-center form-horizontal" id="modal_body">
<form action="/made_payment" method="POST" id="payment-form">
<span class="payment-errors"></span>
<div class="form-group">
<div class="col-xs-12">
<label>
<input class="form-control" type="text" size="20" data-stripe="number" placeholder="Card Number">
</label>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12" style="display: inline-flex;">
<data class="col-xs-6">
<input class="form-control" type="text" size="4" data-stripe="exp_month" placeholder="Exp (MM/YY)">
</data>
<data class="col-xs-6">
<input class="form-control" type="text" size="4" data-stripe="cvc" placeholder="CVC">
</data>
</div>
</div>
</div>
First your html structure need reorganising unless it was intentional. Based on this post - create a no-gutter class and apply to the row where you want to remove the spacing(gutter) between the columns - (I have replaced the data tags with divs for readability) :
.no-gutter {
margin-left: 0;
margin-right: 0;
}
.no-gutter > [class^="col-"] {
padding-left: 0;
padding-right: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="modal-body text-center form-horizontal" id="modal_body">
<form action="/made_payment" method="POST" id="payment-form">
<span class="payment-errors"></span>
<div class="row">
<div class="form-group no-gutter col-xs-6">
<div class="col-xs-12">
<input class="form-control" type="text" data-stripe="number" placeholder="Card Number">
</div>
<div class="col-xs-6">
<input class="form-control" type="text" size="4" data-stripe="exp_month" placeholder="Exp (MM/YY)">
</div>
<div class="col-xs-6">
<input class="form-control" type="text" size="4" data-stripe="cvc" placeholder="CVC">
</div>
</div>
</div>
</form>
</div>
As for the rest of the styling that's up to your css and bootstrap check this out bootstrap input groups - Good luck

Bootstrap 3 checkbox right side of text / button on own row

I have the current setup.
<div class="container" data-ng-controller="publicHome">
<div class="col-md-4 col-md-offset-4" style="background: black;">
<form data-ng-submit="signIn()" class="form-horizontal">
<div class="form-group">
<input type="email" data-ng-model="email" placeholder="email" class="form-control">
</div>
<div class="form-group">
<input type="password" data-ng-model="password" placeholder="password" class="form-control">
</div>
<label class="checkbox pull-right">
remember me
<input type="checkbox" data-ng-model="rememberMe">
</label>
<div class="form-group center-block">
<button type="submit" class="btn btn-success center-block">sign in</button>
</div>
</form>
<div data-ng-bind="message" class="text-center">
</div>
</div>
</div>
I am trying to:
Get the check box on the right side of the remember me text AND have both of the right side of the form
Have the button on it's own row underneath the remember me
As you can see I'm nearly there!
Use:
<div class="form-group mycheckboxdiv">
<label>
remember me
<input type="checkbox" data-ng-model="rememberMe" class="pull-right mycheckbox">
</label>
</div>
and for your own css:
.mycheckbox{
margin-top:5px;
margin-left:5px;
}
.mycheckboxdiv{
text-align:right;
}
See this:
http://www.bootply.com/a6Jl6EDD8R

Aling a div on right

I have this a contact form and I need to float it at the extreme right of its container. How can i do it? I'm trying with everything but nothing happen. Maybe i have to set different class for columns? This is the code:
HTML
<section id="services" class="section text-center">
<div class="container">
<div class="col-md-6 map">
<!-- Responsive iFrame -->
<div class="Flexible-container">
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2694.5937634214993!2d8.0133807!3d47.5173021!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0000000000000000%3A0x9b610c417aa1ee02!2sZAG+Engineering!5e0!3m2!1sde!2sch!4v1443705863599"></iframe>
</div></div>
<div class="col-md-6 form">
<form class="form-horizontal" role="form" method="post" action="index.php">
<div class="form-group">
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name" placeholder="Vorname, Name" value="">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name" placeholder="Firma" value="">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="email" class="form-control" id="email" name="email" placeholder="E-Mail" value="">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name" placeholder="Telefon" value="">
</div>
</div>
<div class="form-group">
<div class="col-sm-10">
<textarea class="form-control" rows="4" name="message" placeholder="Nachricht"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<! Will be used to display an alert to the user>
</div>
</div>
</form></div>
</div>
<!--/.container -->
</section>
CSS
.col-md-6.map { margin-left: -15px; }
.form-horizontal { width: 100%; float: right; }
.form-group { margin-bottom: -25px; }
.col-md-6.form { border: 1px solid red !important; }
Add col-md-offset-2
<div class="form-group">
// place col-md-offset-2 here for each input
<div class="col-sm-10 col-md-offset-2">
<input type="text" class="form-control" id="name" name="name" placeholder="Vorname, Name" value="">
</div>
</div>
inside form-group either change col-sm-10 to col-sm-12 that will make your input fields take entire width of your form or if yo want them right aligned give float:right to your col-sm-10 div it will work
Not sure what you really want, but if you want the whole form being at the extrem right of the screen, you have to remove the fixed width of your div class="container" which is the reason you have white space on right side.
If you want input being on the right side of your red-bordered area, you should put "float:right" on the col-sm-10" class. Hope it helped you

How to align the form horizontally in the middle of the div in bootstrap

<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<form role="form">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label><input type="email" class="form-control" id="exampleInputEmail1" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label><input type="password" class="form-control" id="exampleInputPassword1" />
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label><input type="file" id="exampleInputFile" />
<p class="help-block">
Example block-level help text here.
</p>
</div>
<div class="checkbox">
<label><input type="checkbox" /> Check me out</label>
</div> <button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
</div>
I am using bootstrap.
And I want to align the form in the middle of this div col-md-12 column.
Any solutions for this?
Demo http://bootply.com/103569
Could use an offset like:
<div class="container">
<div class="row clearfix">
<div class="col-md-6 col-md-offset-3 column">
<form role="form">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label><input type="email" class="form-control" id="exampleInputEmail1" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label><input type="password" class="form-control" id="exampleInputPassword1" />
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label><input type="file" id="exampleInputFile" />
<p class="help-block">
Example block-level help text here.
</p>
</div>
<div class="checkbox">
<label><input type="checkbox" /> Check me out</label>
</div> <button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
<div class="row clearfix">
<div class="col-md-12 column">
</div>
</div>
</div>
or
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="col-md-6 col-md-offset-3 column">
<form role="form">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label><input type="email" class="form-control" id="exampleInputEmail1" />
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label><input type="password" class="form-control" id="exampleInputPassword1" />
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label><input type="file" id="exampleInputFile" />
<p class="help-block">
Example block-level help text here.
</p>
</div>
<div class="checkbox">
<label><input type="checkbox" /> Check me out</label>
</div> <button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
</div>
</div>
http://getbootstrap.com/css/#grid-offsetting
You can have two solutions here with the property display.
One with inline-block:
.col-md-12 column {
text-align:center;
}
.col-md-12 column form {
display:inline-block;
}
Two with table :
.col-md-12 column form {
display:table;
margin:auto;
}
If you have a fixed width for the form you only need to add the margin:auto
Give your form a class
<form role="form" class="myForm">
and add the following style to it
.myForm
{
width: 480px;
margin-left: auto;
margin-right: auto;
}
http://bootply.com/103575
I would try adding
class="center"
to
<form role="form">
ending up with
<form role="form" class="center">
and creating the style declaration:
.center{margin:0px auto;}
keeping in mind that .center must have a set width that is less than the width of it's container.
Hope that helps.