Putting div's on the same row - html

It's my understanding that to make div's line up on the save row you just need to make sure the col-sm-#'s add up to 12.
This isn't working for me, and wherever I place the isCoop section in my code, it ends up beneath the row I want. I just want the isCoop section to appear on the same line as the div's above it in this class.
I've changed the col-sm-#'s with no results
<div class="form-group">
<div class="col-sm-1 required campaign-drpdwn">
<select id="campaign" class="form-control font-weight-bold" ng-options="value.key as value.label for value in vm.campaignOptions" ng-model="vm.campaignOption" ng-change="vm.selectCampaignBy()"></select>
</div>
<div class="col-sm-1 no-padding required-div">*</div>
<!--<label class="col-sm-2 control-label">Total Campaign Budget</label>-->
<div class="col-sm-1 input-group" ng-show="!vm.selectCampaign">
<span class="input-group-addon">$</span>
<input type="text" ng-model="vm.Budget" class="form-control col-sm-2" name="budget" id="txtCampaignBudget" placeholder="enter budget" ng-required="!vm.selectCampaign == true" ng-keydown="vm.KeyPressEvent($event,vm.Budget)" ng-blur="vm.formatNumberWithoutDollar(vm.Budget)">
</div>
<span id="budget-lblerror" class="col-sm-offset-1 color-red" ng-show="campaignform.budget.$invalid && (campaignform.budget.$touched || vm.submitted)">Not valid input!</span>
<-- isCoop section -->
<div class="col-sm-3">
<label for="IsCoop" class="col-sm-2 control-label">Coop</label>
<label class="radio-inline">
<input type="radio" ng-model="vm.IsCoop" ng-value="1" name="IsCoop" />Yes
</label>
<label class="radio-inline">
<input type="radio" ng-model="vm.IsCoop" ng-value="0" name="IsNotCoop" />No
</label>
</div>
</div>

Related

Label for checkbox not showing checkmark - MVC bootstrap

I'm using TwitterBootstrapMVC. To generate checkbox from enum, I'm using the below code
#form.FormGroup().CustomControls(Html.Bootstrap().CheckBoxesFromEnum($"{nameof(CSViewModel.Option)}"))
.CustomLabel("Options")
It gets rendered in HTML like this
<div class=" form-group">
<label class="control-label col-sm-1 col-md-1" for="">Options<span class="required" style="visibility:hidden;" wfd-invisible="true">*</span> </label>
<div class="col-xs-11 col-sm-11 col-md-11">
<div class="input-list-container">
<div class="checkbox">
<label for="Option_0">
<input id="Option_0" name="Option" type="checkbox" value="UpdateAsOfDate">UpdateAsOfDate<span class="required" style="visibility:hidden;">*</span>
</label>
</div>
</div>
</div>
</div>
Problem is, when I click on the checkbox, it won't show the checkmark. The label for is not getting linked with the checkbox input.
I tried editing the HTML in the browser by placing the "label for" after the input checkbox, and it works.
<div class=" form-group">
<label class="control-label col-sm-1 col-md-1" for="">Options<span class="required" style="visibility:hidden;" wfd-invisible="true">*</span> </label>
<div class="col-xs-11 col-sm-11 col-md-11">
<div class="input-list-container">
<div class="checkbox">
<input id="Option_0" name="Option" type="checkbox" value="UpdateAsOfDate">
<label for="Option_0">
UpdateAsOfDate
<span class="required" style="visibility:hidden;">*</span>
</label>
</div>
</div>
</div>
</div>
How to make the bootstrap to render the HTML like above ? Or how it can be fixed in bootstrap ?

Rendering checkboxes

I need to make my form look like "Title over the checkbox and text on the right side" and etc. It's like a list of settings
But I can't display it properly
Here is my code
<div class="modal-body">
<form>
<div class="col-md-12">
<div class="form-group col-md-6" style="display: inline-block">
<label for="defaultG">To default view </label>
<input class="form-control" type="checkbox" value="Default" id="defaultG">
</div>
<div class="form-group col-md-6" style="display: inline-block">
<p>Auto generated style due to common stylish rules.</p>
</div>
</div>
<div class="form-group">
<label for="extendedG">To extended view</label>
<input class="form-control" type="checkbox" value="Extended" id="extendedG">
</div>
<div class="form-group">
<label for="CompactG">To Compact view</label>
<input class="form-control" type="checkbox" value="Compact" id="CompactG">
</div>
<div class="form-group">
<label for="extendedBracketsG">Left stady view</label>
<input class="form-control" type="checkbox" value="ExtendedBrackets" id="extendedBracketsG">
</div>
<div class="form-group">
<label for="BeforeG">Comas before</label>
<input class="form-control" type="checkbox" value="Before" id="BeforeG">
</div>
<div class="form-group">
<label for="AfterG">Comas after</label>
<input class="form-control" type="checkbox" value="After" id="AfterG">
<div class="form-group">
<label for="setTrimsAfterDotKomaG">Set trims after ;</label>
<input class="form-control" type="checkbox" value="SetTrimsAfterDotKoma" id="setTrimsAfterDotKomaG">
</div>
<div class="form-group">
<label for="setTrimsBeforeDotKomaG">Set trims before ;</label>
<input class="form-control" type="checkbox" value="SetTrimsBeforeDotKoma" id="setTrimsBeforeDotKomaG">
</div>
<div class="form-group">
<label for="removeTrimsG">Remove trims</label>
<input class="form-control" type="checkbox" value="RemoveTrims" id="removeTrimsG">
</div>
<div class="form-group">
<label for="removeEmptyLinesG">Remove empty lines</label>
<input class="form-control" type="checkbox" value="RemoveEmptyLines" id="removeEmptyLinesG">
</div>
<div class="form-group">
<label for="allVarsUpperCaseG">All variables upper case</label>
<input class="form-control" type="checkbox" value="VarsUpper" id="allVarsUpperCaseG">
</div>
<div class="form-group">
<label for="allVarsLowerCaseG">All variables lower case</label>
<input class="form-control" type="checkbox" value="VarsLower" id="allVarsLowerCaseG">
</div>
<div class="form-group">
<label for="varsUnderscoredG">All variables underscored</label>
<input class="form-control" type="checkbox" value="VarsUnderscored" id="varsUnderscoredG">
</div>
<div class="form-group">
<label for="toExtendedViewG">All variables to extended view</label>
<input class="form-control" type="checkbox" value="ExtendedView" id="toExtendedViewG">
</div>
<div class="form-group">
<label for="removeUnusedVarsG">Remove unused vars</label>
<input class="form-control" type="checkbox" value="removeUnusedVars" id="removeUnusedVarsG">
</div>
</div>
</form>
And I get this https://ibb.co/cqTqaT
I have no idea what the hell is going on with this. Help please!
Thanks!
At first you should check your HTML Structure and used classes.
An example, your following code:
<div class="col-md-12">
<div class="form-group col-md-6" style="display: inline-block">
<label for="defaultG">To default view </label>
<input class="form-control" type="checkbox" value="Default" id="defaultG">
</div>
<div class="form-group col-md-6" style="display: inline-block">
<p>Auto generated style due to common stylish rules.</p>
</div>
</div>
creates a div with two divs inside, which take both 50% width. In the first div with there is the label and also the checkbox. In the second div, there is the text you would like to have beside the checkbox. But this isn't working with your markup.
Better would be the following markup:
<div class="col-md-12">
<div class="form-group">
<label for="defaultG">To default view </label>
<input class="form-control" type="checkbox" value="Default" id="defaultG">
<p>Auto generated style due to common stylish rules.</p>
</div>
</div>
As you can see, I removed the two div's and used only one form-group. With the following simple CSS:
label{
display: block;
}
p {
display: inline-block;
}
You should get the wanted result.

Aligning the controls in a DIV

My second week of learning and doing WebDevelopment! I have written this Bootstrap layout and the result is in the picture below.
Note the areas marked as yellow? why is that happening? How can I fix it? I know I can for example play around with margin-left ,etc.. to make it look right but I am still thinking if I define they correctly in bootstrap, it shouldn't have this problem.
Here is the Bootply to see the issue: http://www.bootply.com/zRyxHyhdbM
Here is the generated HTML code:
<div class="row form-group">
<div class="col-sm-offset-2 col-sm-1 text-right"><label class="control-label" for="Email">Email</label></div>
<div class="col-sm-4">
<input id="AdminEmail" name="AdminEmail" style="width:100%;padding-right:30px;" type="text" value="">
<span class="glyphicon glyphicon-envelope form-control-feedback" style="right: 10px; line-height: 27px;"></span>
</div>
<div class="col-sm-4 col-sm-offset-1">
<div>
<input class="checkbox-inline" id="ShowAdminPhone" name="ShowAdminPhone" type="checkbox" value="true"><input name="ShowAdminPhone" type="hidden" value="false">
<label class="control-label" for="Show_Admin_phone">Show Admin phone</label>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-sm-offset-2 col-sm-1 text-right"><label class="control-label" for="Phone">Phone</label></div>
<div class="col-sm-9 form-group">
<input class="col-sm-2" id="AdminPhone" name="AdminPhone" type="text" value="">
<label class="control-label col-sm-1" for="Ext">Ext</label>
<input class="col-sm-2" id="AdminExt" name="AdminExt" type="text" value="">
</div>
</div>
The misalignment is there because, the email input box is col-sm-4. To align bottom inputs we have to fit them with in col-sm-4. You can add margin-left(approx 12px) to align it but it will not be responsive.
Hence, I have changed the markup a little bit to remain responsive--
Link --- http://www.bootply.com/x0fgleMTp2
<div class="row form-group">
<div class="col-sm-offset-2 col-sm-1 text-right"><label class="control-label" for="Email">Email</label></div>
<div class="col-sm-4">
<input id="AdminEmail" name="AdminEmail" style="width:100%;padding-right:30px;" type="text" value="">
<span class="glyphicon glyphicon-envelope form-control-feedback" style="right: 10px; line-height: 27px;"></span>
</div>
<div class="col-sm-4 col-sm-offset-1">
<div>
<input class="checkbox-inline" id="ShowAdminPhone" name="ShowAdminPhone" type="checkbox" value="true"><input name="ShowAdminPhone" type="hidden" value="false">
<label class="control-label" for="Show_Admin_phone">Show Admin phone</label>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-sm-offset-2 col-sm-1 text-right"><label class="control-label" for="Phone">Phone</label></div>
<div class="col-sm-4 multi-row">
<span class="col-sm-5"><input class="form-input" id="AdminPhone" name="AdminPhone" type="text" value=""></span>
<span class="col-sm-2"><label class="control-label" for="Ext">Ext</label></span>
<span class="col-sm-5"><input class="form-input" id="AdminExt" name="AdminExt" type="text" value=""></span>
</div>
</div>
Is this what you wanted to achieve? Hope it may help.
<div class="container">
<div class="row">
<div class="form-group">
<label for="exampleInputEmail3">Phone</label>
<input type="text" class="form-control" id="exampleInputEmail3" placeholder="Phone">
</div>
<div class="form-inline">
<div class="form-group">
<label for="exampleInputEmail3">Phone</label>
<input type="text" class="form-control" id="exampleInputEmail3" placeholder="Phone">
</div>
<div class="form-group pull-right">
<label for="exampleInputEmail3">Ext</label>
<input type="text" class="form-control" id="exampleInputEmail3" placeholder="Ext">
</div>
</div>
</div>
</div>
The fiddle

decrease input width (using bootstrap)

I am trying to decrease middle name input field but i can't get it work. It only works at xs screen (picture below).
<div class="row">
<form class="form-inline" role="form" name="userForm" novalidate>
<div class="form-group required">
<label for="first" class="control-label">Child's Name</label>
<div class="input-group">
<span class="col-xs-9 col-sm-5">
<input type="text" class="form-control" id='first' name="first" >
<label for ="first">First </label>
</span>
</div>
<div class="input-group">
<span class="col-xs-3 col-sm-2">
<input type="text" class="form-control col-xs-3 col-sm-2" id='mi' name="mi" >
<label for ="mi">MI</label>
</span>
</div>
<div class="input-group">
<span class="col-xs-9 col-sm-5">
<input type="text" class="form-control" id = "last" name="last" >
<label for="last"> Last </label>
</span>
</div>
</div>
</form>
</div>
You're code is wrong please check again.you end the </form> before end other tag. and again read how to use bootstrap form. help this link.
remove span and add col-sm-4 to div
`
<div class="form-group required">
<label for="first" class="control-label">Child's Name</label>
<div class="input-group col-sm-4">
<input type="text" class="form-control" id='first' name="first">
<label for="first">First </label>
</div>
<div class="input-group col-sm-1">
<input type="text" class="form-control " id='mi' name="mi">
<label for="mi">MI</label>
</div>
<div class="input-group col-sm-4">
<input type="text" class="form-control " id="last" name="last">
<label for="last"> Last </label>
</div>
<div class="help-block" ng-messages="userForm.first.$error" style="color:maroon" role="alert">
<p ng-message="required">Child's First Name is required.</p>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-danger">Submit</button>
</div>
</form>`

inline rows within Bootstrap form

I'm trying to build a horizontal form with Bootstrap which has a row of elements on the right hand side of the form like this:
I am having difficulty getting the checkbox, label and input element to sit on a row nicely like that. This is my current attempt. I've added 'checkbox-inline' which gets things on a line, but I can't get the label to move to the middle of the line. Also, the checkboxes are much larger for some reason. Can anyone offer any hints?
The code from the Codepen link:
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label" for="input_staff">Staff Member and Percent Share *</label>
<div class="col-sm-5">
<label class="checkbox-inline col-sm-3">
<input class="form-control" type="checkbox" name="input_staff[]" value="39">BH
</label>
<div class="input-group col-sm-3">
<input class="form-control" type="number" id="input_staff_percent_39" min="0" max="100" value="0" disabled="">
<span class="input-group-addon">%</span>
</div>
<label class="checkbox-inline col-sm-3" for="">
<input class="form-control" type="checkbox" name="input_staff[]" value="11">CC
</label>
<div class="input-group col-sm-3">
<input class="form-control" type="number" id="input_staff_percent_11" min="0" max="100" value="0" disabled="">
<span class="input-group-addon">%</span>
</div>
</div>
</div>
</form>
here is a small example for your checkboxes
one of your mistakes: Don't use col with other elements, like labels. Preferably you use a div for cols, just use it for cols.
<div class="container">
<form class="form-horizontal">
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
</div>
</form>
</div>
I finally got it working by using the 'form-inline' class for each row. This answer made me go back and look at form-inline again.
Here is my sample code:
<form class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label" for="input_staff">Staff Member and Percent Share *</label>
<div class="col-sm-10">
<div class="form-inline">
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" name="input_staff[]" value="39">BH
</label>
</div>
<div class="input-group col-sm-9">
<input class="form-control" type="number" id="input_staff_percent_39" min="0" max="100" value="0" disabled="">
<span class="input-group-addon">%</span>
</div>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" name="input_staff[]" value="11">CC
</label>
</div>
<div class="input-group col-sm-9">
<input class="form-control" type="number" id="input_staff_percent_11" min="0" max="100" value="0" disabled="">
<span class="input-group-addon">%</span>
</div>
</div>
</div>
</div>
</div>
</form>
Here is a codepen with the code above showing what it looks like.