<div class="form-group">
<label class="lable label-default"> Google Location</label>
<input class="form-control" type="text" name='latitude' placeholder="latitude"
[(ngModel)]="tourDetails.latitude">
<input class="form-control" type="text" name='longitude' placeholder="longitude"
[(ngModel)]="tourDetails.longitude">
</div>
My Css code:
label {
display: inline-block;
width: 140px;
text-align: left;
}
input {
display: inline-block;
width: 140px;
text-align: left;
}
I have my Following Output. But I want to align these input text fields one by one with same proper alignment.
Share your css to properly understand the style, but I am assuming the typo lable instead of label may affect the css rules
<div class="form-group">
<label class="label label-default"> Google Location</label>
<input class="form-control" type="text" name='latitude' placeholder="latitude"
[(ngModel)]="tourDetails.latitude">
<input class="form-control" type="text" name='longitude' placeholder="longitude"
[(ngModel)]="tourDetails.longitude">
</div>
I've done only for geo-location. But if like to get the idea of bootstrap, you can refer W3schools or Bootstrap offcial web
The working fiddle Jsfiddle
<div class="container">
<form class="form-horizontal">
<div class="row">
<div class="col-xs-6">
<label class="control-label label-default"> Google Location</label>
</div>
<div class="col-xs-6">
<div class="form-group">
<input class="form-control" type="text" name='latitude' placeholder="latitude"
[(ngModel)]="tourDetails.latitude">
<input class="form-control" type="text" name='longitude' placeholder="longitude"
[(ngModel)]="tourDetails.longitude">
</div>
</div>
</div>
</form>
</div>
Update 1 As you updated the requirement, I've updated the fiddle too. So you can easily remove <div class="row"> and get your expectation
Related
is it possible in bootstrap?
I implement two-line label and input.
<div class="form-group">
<label for="example">LABEL<span style="color:red">*</span></label>
<input id="example" class="form-control" type="text"/>
</div>
But I want to make these in one-line when the display width is over sm size.
So, I edit my code as follows.
<div class="form-group">
<div class="col-md-2">
<label for="example">LABEL<span style="color:red">*</span></label>
</div>
<div class="col-md-10">
<input id="example" class="form-control" type="text"/>
</div>
</div>
It looks fine except for some margin issues.
But I also want that label width size is fixed so that only input width size is flexible to right side.
Is it possible? Thanks in advance.
Try to use form-horizontal or form-inline class of bootstrap
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
</form>
Please apply this code:
label {
width: auto;
display: inline-block;
}
#example {
width: auto;
display: inline-block;
margin-left: 15px;
}
<div class="form-group">
<label for="example">LABEL<span style="color:red">*</span></label>
<input id="example" class="form-control" type="text"/>
</div>
I hope it is helpful for you.
Thanks
With the below code, the summary and it's text box are aligned inline.But the text box for description is appearing below the label 'description'. How can I make it align inline? Please help me in resolving this.
.left {
width: 30%;
float: left;
text-align: right;
}
.right {
width: 65%;
margin-left: 10px;
float: left;
}
<body>
<div class="container">
<div class="row">
<div class="col-sm-5 col-sm-push-3 col-xs-4 col-xs-push-2">
<h1 class="text-center" style="font-family:Colonna MT;font-size:50px;color:ForestGreen ;">Post Your Ad</h1>
<form action="post" class="login-form">
<div>
<label class="left">Summary:</label>
<input class="right" type="text" name="Summary" size="50">
</div>
<div>
<label class="left">Description:</label>
<input class="right" type="text" name="Description" style="height:100px;width:400px">
</div>
</form>
</div>
</div>
</div>
Try like this: Demo
If you need multi line text box, use textarea instead of input type text
<div class="form-group row">
<label for="inputEmail3" class="col-md-6 col-sm-12 form-control-label text-right">Summary</label>
<div class="col-md-6 col-sm-12">
<input type="text" class="form-control" name="Summary" size="50">
</div>
</div>
<div class="form-group row">
<label for="inputEmail3" class="col-md-6 col-sm-12 form-control-label text-right">Description</label>
<div class="col-md-6 col-sm-12">
<textarea class="form-control" name="Description"></textarea>
</div>
</div>
Edit:
As you mentioned, its not form-control class, its form-control-label.. You can get more info here
Updated Demo: To change the height, try chnaging the value of rows="8" for <textarea>
If you're using Bootstrap (as the classes on your code suggest). I would recommend using their form layout options. Sounds like you want a Horizontal Form:
Docs
For Example:
<form class="form-horizontal">
<div class="form-group">
<label for="summary" class="col-sm-2 control-label">Summary</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="summary" />
</div>
</div>
<div class="form-group">
<label for="description" class="col-sm-2 control-label">Description</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="description" style="height:100px;width:400px" />
</div>
</div>
</form>
<input class="right" type="text" name="Description" style="height:100px;width:400px;">
Remove width from input of description, also please change to textarea, instead of input.
You have already used bootstrap framework.so that there is no need to write extra css for inline forms. follow the following code
<div class="form-group">
<label class="col-lg-3 control-label ">City</label>
<div class="col-lg-9">
<div class="form-inline">
<div class="form-group ">
<div class="col-lg-12">
<label class="sr-only" for="city">City</label>
<input type="text" id="city" name="city" class="form-control " placeholder="E.g. Thrissur" >
</div>
</div>
<div class="form-group ">
<div class="col-lg-12">
<label class="sr-only" for="county">County</label>
<input type="text" id="county" name="county" class="form-control " placeholder="E.g. India" >
</div>
</div>
</div>
</div>
</div>
Like this?
https://jsfiddle.net/d6tscd18/
.left {
width: 30%;
display: inline-block;
text-align: right;
}
.right {
width: 65%;
margin-left: 10px;
display: inline-block;
}
try this:
<html>
<head>
<title>sample</title>
<style type="text/css">
.left {
width: 30%;
display: inline-block;
text-align: right
}
.right {
margin-left: 10px;
display: inline-block;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-5 col-sm-push-3 col-xs-4 col-xs-push-2">
<h1 class="text-center" style="font-family:Colonna MT;font- size:50px;color:ForestGreen ; text-align: center">Post Your Ad</h1>
<form action="post" class="login-form">
<div>
<label class="left">Summary:</label>
<input class="right" type="text" name="Summary" size="50" style="width:400px">
</div>
<div>
<label class="left">Description:</label>
<input class="right" type="text" name="Description" style="height:100px;width:400px">
</div>
</form>
</div>
</div>
</div>
</body>
</html>
If you have trouble getting it in place you can also force a table layout without using tables:
.login-form {
display: table;
}
.login-form>div {
display: table-row;
}
.cell {
display:table-cell;
vertical-align: top;
}
...
Adding a div around the inputs and a "cell" class (and shouldn't it be a textarea?):
...
<form action="post" class="login-form">
<div>
<label class="left cell">Summary:</label>
<div class="cell">
<input class="right" type="text" name="Summary" size="50">
</div>
</div>
<div>
<label class="left cell">Description:</label>
<div class="cell">
<textarea class="right" name="Description" style="height:100px;width:400px"></textarea>
</div>
</div>
</form>
...
Check it here
Remove the style attribute from the description input type, it will then appear as the summary input box.
<form action="post" class="login-form">
<div>
<label class="left">Summary:</label>
<input class="right" type="text" name="Summary" size="50" style="width:400px">
</div>
<div>
<label class="left">Description:</label>
<input class="right" type="text" name="Description">
I've a simple row where there's a label and two input type number
<form class="form-horizontal">
<br>
<div class="container">
<label class="col-sm-2 control-label">Numero documento:</label>
<div class="col-sm-3">
<input type="number" id="firstDocumentNumber" class="form-control">
</div>
<div class="col-sm-1">
<input type="number" id="secondDocumentNumber" class="form-control">
</div>
</div>
</form>
I need to insert a slash ( / ) between the two input type like this
Can anyone help me, please? Here there's the code I use Bootply
Thanks in advance
Simplest way I found is with CSS (tried with Bootstrap 4):
<div class="col-sm-1" id="secondDocumentNumberCont">
<input type="number" id="secondDocumentNumber" class="form-control">
</div>
#secondDocumentNumberCont:before {
content: '/';
position: absolute;
margin-left: -8px;
line-height: 2.3em;
}
margin-left & line-height might require some tuning.
You shuold use a span and format with size and align how you prefer..
<div class="site-index">
<div class="body-content">
<form class="form-horizontal">
<br>
<div class="container">
<label class="col-sm-2 control-label">Numero documento:</label>
<div class="col-sm-3">
<input type="number" id="firstDocumentNumber" class="form-control">
</div>
<span class="col-sm-1 text-right" > / </span>
<div class="col-sm-1">
<input type="number" id="secondDocumentNumber" class="form-control">
</div>
</div>
</form>
or use an add-on
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">/</span>
<input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
</div>
I am using the following code for my inline form (bootstrap 3) but that doesn't seem to work with Google Chrome. I tried it with Firefox and it worked great. Screenshots:
Chrome
http://oi58.tinypic.com/148jjw5.jpg
Firefox
http://oi58.tinypic.com/5fiy41.jpg
The HTML and CSS I'm using:
<style>
.form-inline .form-group {
margin-right: 10px;
margin-left: 4px;
}
.form-inline > .form-group {
vertical-align: top;
}
</style>
<form id="callForm" action="sendCall.php" method="post" class="form-inline" >
<div class="form-group col-md-2">
<div class="input-group">
<label class="sr-only" for="your">Your phone number</label>
<span class="input-group-addon">+91</span>
<input type="text" class="form-control" id="your" name="your" placeholder="Your 10 digit number" required />
</div>
</div>
<div class="form-group col-md-2">
<div class="input-group">
<label class="sr-only" for="frnd">Friend's number</label>
<span class="input-group-addon">+</span>
<input text="text" class="form-control" id="frnd" name="frnd" placeholder="Your friend's number" required />
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success">Connet</button>
</div>
</form>
<script>
You should not put your sr-only element inside the input-group:
<div class="form-group col-md-2">
<label class="sr-only" for="your">Your phone number</label>
<div class="input-group">
<span class="input-group-addon">+91</span>
<input type="text" class="form-control" id="your" name="your" placeholder="Your 10 digit number" required />
</div>
</div>
Anyway, if this fix an extra border (and maybe a floating issue), I doubt this is the only thing to change.
You may have another CSS rule which broke your layout.
For me its working fine on both browser, may be your CSS is not working properly or you are using the old version CSS.
check your css or may be some other properties are overwriting your css that could be the problm.
their is no problem in this code.
<form class="form-inline" >
<div class="form-group col-md-2">
<div class="input-group">
<label class="sr-only" for="frnd">Friend's number</label>
<span class="input-group-addon">+</span>
<input text="text" class="form-control" id="frnd" name="frnd" placeholder="Your friend's number" required />
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success">Connet</button>
</div>
</form>
Without the use of tables, using CSS, how can i align a group of labels and their associated input controls like below (these controls will be in a div):
The controls will be laid out like:
[Label1] [Input1] [Label4] [Input4]
[Label2] [Input2] [Label5] [Input5]
[Label3] [Input3] [Label6] [Input6]
This is kind of open-ended, since a lot depends on the questions, the labels and other specific considerations that you may have for your code.
However, the easiest way to accomplish something like this (IE8+) is probably to use display:table and display:table-cell.
Here's a quick fiddle that basically does that: http://jsfiddle.net/cwz3g/
It uses a lot of divs: one per column, one per label/field pairing and one each for the label and field, but should cover a lot of the common things like vertical alignment of labels and fields. You'll probably just need to tweak some things for your code situation, but it should get you started.
For your two columns, you'll want to put them in container divs, which could then be floated against each other or absolutely positioned, or whatever works for your layout.
To make the labels take up the same amount of room, they can be styled with a width attribute.
Finally, in your diagram, you've got the labels left-justified and the inputs right-justified. That's doable, but to my eyes it scans better if the inputs are justified toward their labels.
I've got it all in a fiddle here: http://jsfiddle.net/M7AjF/
<div class="form-column">
<label for="Input1">Option 1</label>
<select id="Input1"><option>All</option></select>
<br>
<label for="Input2">Option 2</label>
<input id="Input2" type="text"/>
<br>
<label for="Input3">Option 3</label>
<input id="Input3" type="text"/>
</div>
<div class="form-column">
<label for="Input4">Option 4</label>
<select id="Input4"><option>--</option></select>
<br>
<label for="Input5">Option 5</label>
<select id="Input5"><option>0</option></select>
<br>
<label for="Input6">Option 6</label>
<select id="Input6"><option>1</option></select>
</div>
And the css:
.form-column {
width: 50%;
float:left;
}
.form-column label {
width: 40%;
padding-right: 10%;
}
/*
This right justifies your inputs, which I don't recommend.
.form-column select, .form-column input {
float: right;
}
.form-column br {
clear: right;
}
*/
I suggest to use display:table layout like this:
html
<div class="table">
<div class="row">
<div class="cell"><label>Option 1</label></div>
<div class="cell"><select><option>ALL</option></select></div>
<div class="cell"><label>Option 4</label></div>
<div class="cell"><select><option>--</option></select></div>
</div>
<div class="row">
<div class="cell"><label>Option 2</label></div>
<div class="cell"><input type="text"></input></div>
<div class="cell"><label>Option 5</label></div>
<div class="cell"><input type="text"></input></div>
</div>
<div class="row">
<div class="cell"><label>Option 3</label></div>
<div class="cell"><input type="text"></input></div>
<div class="cell"><label>Option 6</label></div>
<div class="cell"><select><option>1</option></select></div>
</div>
</div>
css
.table{
display:table;
}
.row{
display:table-row;
}
.cell{
display:table-cell;
}
.table > .row > .cell{
text-align: right;
padding-right: 75px;
}
.table > .row > .cell > input{
width:75px;
}
fiddle
you can use bootstrap.css for easy way.
http://getbootstrap.com/components/
check my fiddle.
<form class="form-horizontal" role="form" method="post" action="">
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-4">Title</label>
<div class="col-xs-8">
<input name="title" type="text" class="form-control" value="Circular Countdown"/>
</div>
</div>
<div class="form-group">
<label class="col-xs-4">Title</label>
<div class="col-xs-8">
<input name="title" type="text" class="form-control" value="Circular Countdown"/>
</div>
</div>
<div class="form-group">
<label class="col-xs-4">Title</label>
<div class="col-xs-8">
<input name="title" type="text" class="form-control" value="Circular Countdown"/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-4">Title</label>
<div class="col-xs-8">
<input name="title" type="text" class="form-control" value="Circular Countdown"/>
</div>
</div>
<div class="form-group">
<label class="col-xs-4">Title</label>
<div class="col-xs-8">
<input name="title" type="text" class="form-control" value="Circular Countdown"/>
</div>
</div>
<div class="form-group">
<label class="col-xs-4">Title</label>
<div class="col-xs-8">
<input name="title" type="text" class="form-control" value="Circular Countdown"/>
</div>
</div>
</div>
</form>
http://jsfiddle.net/4M7qH/