Grid using float left is leaving gaps - html

I have a simple css which floats elements to the left and creates a table structure. I wanted the table to be dynamic, being able to add a column if the user expands the browser so I have used elements that float left. However it sometimes does not work. I have created a jsfiddle that shows the scenario.
It works for one column, two columns but it does not work for three columns and it leaves a gap.
I cannot understand why it is leaving that gap. Here's the fiddle
http://jsfiddle.net/workmonitored/hgt9Lp5n/12/
html
<div style="margin-left:5px;margin-right:15px">
<div class="keepTogether">
<div class="description">Flows 1:</div>
<div class="userOutput">
<input type="text" name="DetailProjectReportingPeriodDetailEditUI.employeeName">
</div>
</div>
<div class="keepTogether">
<div class="description">Flows 2:</div>
<div class="userOutput">
<input type="text" name="DetailProjectReportingPeriodDetailEditUI.employeeName">
</div>
</div>
<div class="keepTogether">
<div class="description">Flows 3:</div>
<div class="userOutput">
<input type="text" name="DetailProjectReportingPeriodDetailEditUI.employeeName">
</div>
</div>
<div class="keepTogether">
<div class="description">Flows 4:</div>
<div class="userOutput">
<input type="text" name="DetailProjectReportingPeriodDetailEditUI.employeeName">
</div>
</div>
<div class="keepTogether">
<div class="description">Employee Name:</div>
<div class="userOutput">
<input type="text" name="DetailProjectReportingPeriodDetailEditUI.employeeName" style="width: 90%">
</div>
</div>
<div class="keepTogether">
<div class="description">Affiliation</div>
<div class="userOutput">
<select>
<option value="1">Member</option>
<option value="1">Member Spouse</option>
</select>
</div>
</div>
<div class="keepTogether">
<div class="description">Job Title</div>
<div class="userOutput">
<select>
<option value="1">Mr smith</option>
<option value="1">Mrs smith</option>
</select>
</div>
</div>
<div class="keepTogether">
<div class="description">Classification</div>
<div class="userOutput">
<select>
<option value="1">Worker Bee</option>
<option value="1">Grasshoper Initiate</option>
</select>
</div>
</div>
<div class="keepTogether">
<div class="description">Hire Date</div>
<div class="userOutput">
<input type="text" id="hiredate" name="DetailProjectReportingPeriodDetailEditUI.hireDateStr" style="width: 90%">
</div>
</div>
<div class="keepTogether">
<div class="description">Job Status</div>
<div class="userOutput">
<input type="text" id="hiredate" name="DetailProjectReportingPeriodDetailEditUI.hireDateStr" style="width: 90%">
</div>
</div>
<div class="keepTogether">
<div class="description">Pay Scale</div>
<div class="userOutput">
<input name="DetailProjectReportingPeriodDetailEditUI.payScale" size="12">
</div>
</div>
<div class="keepTogether">
<div class="description">Notes</div>
<div class="userOutput">
<textarea rows="1" name="DetailProjectReportingPeriodDetailEditUI.note" style="width: 99%"></textarea>
</div>
</div>
<div style="clear:both; height:5px"></div>
<div class="keepTogether">
<button id="saveReportingPeriodDetail">Save</button>
<button id="cancelReportingPeriodDetail">Cancel</button>
</div>
css
.description {
width: 120px;
float: left;
}
.userOutput {
width: 240px;
float: left;
}
.userInput {
width: 240px;
float: left;
}
.keepTogether {
display:inline;
float:left;
margin-bottom: 2px;
}
.keepTogether select {
width: 220px;
}
.keepTogether input {
width: 120px;
float: left;
}
Thanks in advance.

Setting the margin on input and select elements to 0 sorted out the issue also.
.keepTogether input {
width: 120px;
float: left;
margin: 0;
}
http://jsfiddle.net/hgt9Lp5n/13/

Related

Aligning controls using html / bootstrap

I am trying to align the controls in my angular 8 application. Basically I need to align the Amount column like shown in the screenshot below. Could somebody tell me how to achieve that. Currently using col-sm-5 for Amount column. If I do col-sm-6 it would push the edit button further out which i don't want.I need to get the textbox upto the red line shown in screenshot 1
screenshot 1
Screenshot 2
<form [formGroup]="settlementForm" (ngSubmit)="addAccount()" class="form-horizontal argentex-form" novalidate>
<div class="modal-body">
<div *ngIf="messageViewerModel.messages.length > 0" class="viewer">
<app-message-viewer [messageViewer]="messageViewerModel"></app-message-viewer>
</div>
<!-- Remaining balanace input -->
<div class="form-group has-feedback">
<label class="col-sm-4 control-label">Remaining Balance</label>
<div class="col-sm-6">
<currency class="form-control" [stringModel]="remainingBalance()" [isDisabled]="true"></currency>
</div>
</div>
<!-- Dropdown Accounts -->
<div class="form-group">
<label class="col-sm-4 control-label">Account</label>
<div class="col-sm-6">
<div class="selectdiv">
<select class="form-control" id="selectedAccount" #selectedAccountID
name="selectedAccountFormControl" formControlName="selectedAccountFormControl">
<option *ngFor="let account of accounts; let ind=index;" value="{{ ind }}"
ngDefaultControl>
{{ account.accountName }}
</option>
</select>
</div>
</div>
</div>
<!-- Amount in the traded currency -->
<div class="form-group has-feedback">
<label class="col-sm-4 control-label">Amount ({{settlement.tradedCurrency}})</label>
<div class="col-sm-5">
<currency class="form-control" [isDisabled]=editMode [(numModel)]="settlement.amount" [stringModel]="settlement.amount"
[required]="true" [readonly]="settlement.isPayTotal"></currency>
</div>
<div class="col-sm-1" style="padding-top: 5px">
<!-- settlement?.isPayTotal -->
<div *ngIf="editMode">
<a href="javascript:;" class="btn-edit" (click)="editAmount()">
<img src="../../assets/images/icon-sp-edit.png" alt=""/>
</a>
</div>
<div *ngIf="!editMode">
<a href="javascript:;" class="btn-edit" (click)="cancelAmount()">
<img src="../../assets/images/icon-sp-cancel.png" alt=""/>
</a>
</div>
</div>
</div>
<!-- Value Date -->
<div class="form-group has-feedback">
<label class="col-sm-4 control-label">Value Date</label>
<div class="col-md-6">
<input type="text"
name="valueDate"
formControlName="valueDate"
class="form-control"
[(ngModel)]="settlement.valueDate"
bootstrapDatepicker />
</div>
</div>
<!-- Reference -->
<div class="form-group">
<label class="col-sm-4 control-label">Reference</label>
<div class="col-sm-6">
<input type="text" formControlName="reference" name="reference" class="form-control"
[(ngModel)]="settlement.reference" />
</div>
</div>
</div>
<div class="modal-footer">
<hr>
<button type="submit" class="btn" [disabled]="settlementForm.disabled || !settlementForm.valid || selectedAccountID.value <= 0 || !settlement.amount" >Save</button>
<button type="button" class="btn btn-close" (click)="closeModal()">Cancel</button>
</div>
</form>
Proposed solution
Its near but not still what I want
screenshot
Used the folowing css
.custom-css-input {
width: 100%;
/* float: left; */
}
.icon-button {
width: 40px;
float: left;
}
p.clear {
clear: both;
margin: 0;
padding: 0;
height: 0;
}
Following html
<div class="form-group has-feedback">
<label class="col-sm-4 control-label">Amount ({{settlement.tradedCurrency}})</label>
<div class="col-sm-5" >
<currency class="form-control custom-css-input" [(numModel)]="settlement.amount" [(stringModel)]="settlement.amount"
[isDisabled]=!editMode [required]="true" ></currency>
</div>
<div style="padding-top: 5px">
<div *ngIf="!editMode" class="icon-button">
<a href="javascript:;" class="btn-edit" (click)="editAmount()">
<img src="../../assets/images/icon-sp-edit.png" alt="" />
</a>
</div>
<div *ngIf="editMode" class="icon-button">
<a href="javascript:;" class="btn-edit" (click)="cancelAmount()">
<img src="../../assets/images/icon-sp-cancel.png" alt="" />
</a>
</div>
</div>
<p class="clear"></p>
</div>
sry for not posting bootstrap solution, but if you are in hurry, simple css can work for you. I have added three custom css classes (custom-css-input,icon-button,clear), .clear is only there if floats disturb the rest of your form, but that's just in case. You can play width calc width and fixed width in order to achive your desired look. (Wrap whole input+button component in one single column and play inside with widths)
.custom-css-input {
width: calc(100% - 50px);
float: left;
}
.icon-button {
width: 40px;
float: right;
}
p.clear {
clear: both;
margin: 0;
padding: 0;
height: 0;
}
<div class="col-sm-6">
<currency class="form-control custom-css-input" [isDisabled]=editMode [(numModel)]="settlement.amount" [stringModel]="settlement.amount" [required]="true" [readonly]="settlement.isPayTotal"></currency>
<div *ngIf="editMode" class="icon-button">
<a href="javascript:;" class="btn-edit" (click)="editAmount()">
<img src="../../assets/images/icon-sp-edit.png" alt="" />
</a>
</div>
<div *ngIf="!editMode" class="icon-button">
<a href="javascript:;" class="btn-edit" (click)="cancelAmount()">
<img src="../../assets/images/icon-sp-cancel.png" alt="" />
</a>
</div>
<p class="clear" />
</div>

bootstrap placeholder not working on a input type

I have a HTML which has a div with multiple inputs(with placeholder). For some reason the placeholder is not displayed properly.Also, need the 2 input button(text) to be placed next to each other.
Here is the jsfiddle.
http://jsfiddle.net/o2qt6910/
HTML
<div class="container">
<div class="row row-bordered voffset4">
<div class="col-md-12">
<label class="radio-inline"><input type="radio" name="optradio">Aisles</label>
<label class="radio-inline"><input type="radio" name="optradio">Poses</label>
<label class="radio-inline"><input type="radio" name="optradio">Exclusion Zones</label>
</div>
</div>
<div class="row row-bordered">
<div class="col-md-4">
<button type="button" class="btn" id="add-aisle">Add</button>
<div id="aisle-coordinate-container">
<div class="col-md-1"> <input type="text" class="form-control" id="inputKey" placeholder="X"> </div>
<div class="col-md-1"> <input type="text" class="form-control" id="inputValue" placeholder="Value"> </div>
</div>
</div>
<div class="col-md-8">
<canvas id="myCanvas"></canvas>
</div>
</div>
<!--<div class="row">-->
<!--<img src="/static/images/lena.png" alt="Italian Trulli">-->
<!--</div>-->
</div>
CSS
#import "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css";
.row-bordered:after {
content: "";
display: block;
border-bottom: 5px solid #ccc;
margin: 0 25px;
}
.voffset { margin-top: 2px; }
.voffset1 { margin-top: 5px; }
.voffset2 { margin-top: 10px; }
.voffset3 { margin-top: 15px; }
.voffset4 { margin-top: 30px; }
.voffset5 { margin-top: 40px; }
.voffset6 { margin-top: 60px; }
.voffset7 { margin-top: 80px; }
.voffset8 { margin-top: 100px; }
.voffset9 { margin-top: 150px; }
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}
Try this:
<div class="row row-bordered">
<div class="col-md-4">
<div class="col-xs-12">
<button type="button" class="btn col-xs-2" id="add-aisle">Add</button>
</div>
<div id="aisle-coordinate-container">
<div class="col-sm-6">
<input type="text" class="form-control" id="inputKey" placeholder="X">
</div>
<div class="col-sm-6">
<input type="text" class="form-control" id="inputValue" placeholder="Value">
</div>
</div>
</div>
<div class="col-md-8">
<canvas id="myCanvas"></canvas>
</div>
</div>
There is some issue in Fiddle in alignments. I've tested this in my browser, input elements are now in one line with placeholders visible properly.
<div class="row row-bordered">
<div class="col-md-4">
<button type="button" class="btn" id="add-aisle">Add</button>
</div>
</div>
<div class="row">
<div id="coordinate-container">
<div class="col-md-3 col-sm-3"> <input type="text" class="form-control" id="inputKey" placeholder="X"> </div>
<div class="col-md-3 col-sm-3"> <input type="text" class="form-control" id="inputValue" placeholder="Value"> </div>
</div>
</div>
<div class="col-md-8">
<canvas id="myCanvas"></canvas>
</div>
</div>
Is this how you want it to be? I'm having a hard time visualising what is it that you want.
Do you want the add button and the inputs on the same line or next?
Edit: Changed the button to be on another row. There is no need for it to be on the same row, if you want it on another line.
Its not an issue with the code but more how you are using the bootstrap grid. Your parent container has col-md-4 but the div with the input boxes have col-md-1 which only 1/4th of the width to be shown so its squished down. If you remove the col-md-1 classes it shows up correctly.
Quick suggestion: If you want to use a col-md-x class you can add row class to the <div id="coordinate-container">

CSS and modifying div's width if radio button checked

JavaScript not accepted this time.
So, I have this CSS code. This code should change to width if radio button is checked. Nothing happens. How could I modify the code?
input[type="radio"]#someID-1:checked #extra { width: 4000px; }
I also have this HTML code:
<div id="kaaviotaulukko" style="white-space: nowrap; position: relative; text-align: center;">
<div style="display: inline-block">
<div style="DISPLAY:INLINE-BLOCK">
<input id="someID-1" name="nappi" type="radio">
<div class="listaus-sisalto" style="float:left;width:0">
<div id="navi3">
<div style="z-index:100;position:fixed;right:0;top:300px">
<span><label for="someID-1">1</label></span>
</div>
</div>
</div>
<div class="kierros" style="display: inline-block;width:350px">
R1
</div>
</div>
<div style="DISPLAY:INLINE-BLOCK">
<input id="someID-5" name="nappi" type="radio">
<div class="listaus-sisalto" style="float:right;width:0">
<div id="navi5"></div>
</div>
<div class="kierros" id="extra" style="display: inline-block;width:70px">
extra
</div>
</div>
<input id="someID-100" name="nappi" type="radio">
<div class="listaus-sisalto" style="float:right;width:0">
<div id="navi100"></div>
</div>
<div style="z-index:99;width:70px;position:fixed;left:0;top:100px;margin:auto;background-color:red">
<br>
</div>
<div style="z-index:99;width:70px;position:fixed;right:0;top:100px;margin:auto;background-color:red">
<br>
</div>
</div>
</div>
There is no child #extra of that input. Just remove that from the selector.
input[type="radio"]#someID-1:checked {
width: 4000px;
}
<div id="kaaviotaulukko" style="white-space: nowrap; position: relative; text-align: center;">
<div style="display: inline-block">
<!--
-->
<DIV STYLE="DISPLAY:INLINE-BLOCK"><input name="nappi" type="radio" id="someID-1" />
<div class="listaus-sisalto" style="float:left;width:0">
<div id="navi3">
<div style="z-index:100;position:fixed;right:0;top:300px"><span><label for="someID-1">1</label></span></div>
</div>
</div>
<div class="kierros" style="display: inline-block;vertical-align:top;width:350px">R1
</div>
</DIV>
<!--
-->
<DIV STYLE="DISPLAY:INLINE-BLOCK"><input name="nappi" type="radio" id="someID-5" />
<div class="listaus-sisalto" style="float:right;width:0">
<div id="navi5">
</div>
</div>
<div class="kierros" style="display: inline-block;vertical-align:top;width:70px" id="extra">extra
</div>
</DIV>
<!--
--><input name="nappi" type="radio" id="someID-100" />
<div class="listaus-sisalto" style="float:right;width:0">
<div id="navi100">
</div>
</div>
<!--
-->
<div style="z-index:99;width:70px;position:fixed;left:0;top:100px;margin:auto;background-color:red"><br />
</div>
<div style="z-index:99;width:70px;position:fixed;right:0;top:100px;margin:auto;background-color:red"><br />
</div>
</div>
</div>
The selector input[type="radio"]#someID-1:checked #extra selects an element with the id extra that is a child element of your radio button. Since radio buttons rarely have children, you'll need to change the selector to match your HTML structure.
I suggest placing the radio button inside the same parent element as #extra. That way you can use the selector input[type="radio"]#someID-1:checked ~ #extra which will target the #extra element if it is preceded by the radio button in selected state.
A simplified version of what you'd like to become.
#radiodiv {
background: red;
}
#radio:checked + #radiodiv {
width: 400px;
}
<input id="radio" type="radio" />
<div id="radiodiv">
<p>This is the div</p>
</div>

Select tag gets "disabled" on a certain screen size

I have a new weird html/bootstrap/jquery problem... When the screen have a certain width (more than the nav-toggle width, but less than the normal width), all select boxes gets "disabled".
Check my jsFiddle here. Notice then on wide screens it works perfectly, but on medium sies it does not show, while om small it works good again.
Don't really know how to search for this problem, but the searches I have done have returned nothing of interrest. Hope you guys have a clue...
I have tested the latest Chrome, and IE, an interresting thing though is that earlier versions of IE works as expected (9 and 10), but Edge/11 does not work.
<div class="container kidliste" style="" id="HEADER_243">
<div class="row" onclick="clickMessageList(243);">
<div class="col-sm-3">
<div class="text-left" style="display: inline-block; font-size: 0.8em; margin-top: 7px; margin-left: 2px">
<i class="fa fa-clock-o"></i> 27.02.2014 - 23:31
</div>
<div class="text-right" style="display: inline-block; font-size: 0.8em;">
<i class="fa fa-phone"></i> 40055206
</div>
</div>
<div class="col-sm-7">
<div style="display: inline-block">
<p style="margin: 0; overflow: hidden; height: 1.2em; margin: 3px;">
<a style=" ">test pricegroup</a>
</p>
</div>
</div>
<div class="col-sm-2 text- text-right">
</div>
</div>
</div>
<div class="panel panel-default midliste" data-kid="243" id="MELDINGER_243" style="margin: 0 0 25px 80px">
<div class="panel" style="margin: 2px;padding: 0; margin-bottom: 5; padding-bottom: 0; color: #D17600">
<div class="row">
<div class="col-sm-2" style="padding: 2px; margin-left: 15px">
27.02.2014 - 23:31 </div>
<div class="col-sm-7" style="display: inline-block ; min-height: 3em;">
test pricegroup </div>
<div class="col-sm-2 pull-right text-right" style="margin-right: 25px;">
<a onclick="confirmSensur(1043, 243)" style="text-decoration: underline; font-size: 0.8em;">Sensurer melding!</a>
</div>
</div>
</div>
<div class="panel" style="margin: 2px;padding: 0; margin-bottom: 5; padding-bottom: 0; color: grey">
<div class="row">
<div class="col-sm-2" style="padding: 2px; margin-left: 15px">
27.02.2014 - 23:31 </div>
<div class="col-sm-7" style="display: inline-block ; min-height: 3em;">
Meldingen er mottatt og vil bli behandlet så snart som mulig. Mvh Legene på Høyden </div>
<div class="col-sm-2 pull-right text-right" style="margin-right: 25px;">
</div>
</div>
</div>
<div class="panel" style="margin: 2px;padding: 0; margin-bottom: 0; padding-bottom: 0">
<div class="row">
<div class="col-md-2" style="margin-left: 15px"></div>
<div class="col-md-8">
<form class="form-inline sendMessage" id="sendMessage_243" role="form" method="post" action="index2.php?page=Innboks&action=sendMelding">
<input type="hidden" name="kid" value="243">
<input type="hidden" name="type" value="0">
<div class="input-group">
<span class="input-group-addon btn btnStandardmelding" onclick="$(this).MessageWiz('#TEXT_243')">
Standardmelding <i class="fa fa-caret-right"></i>
</span>
<textarea id="TEXT_243" name="msg" class="form-control custom-control" rows="2" style="resize:none;"></textarea>
<span onclick="$(this).parents('form').submit()" class="input-group-addon btn">Send</span>
</div>
</form>
</div>
</div>
</div>
<div class="panel" style="margin: 2px;padding: 0; margin-bottom: 0; padding-bottom: 0">
<div class="row">
<div class="col-md-2" style="margin-left: 15px"></div>
<div class="col-md-8">
<form id="oppdaterStatus_243" action="index2.php?page=Innboks&action=oppdaterStatus" method="post" class="form-horizontal oppdaterStatus">
<input type="hidden" name="kid" value="243">
<div class="form-group container" style="margin-left: -15px">
<label class="control-label col-sm-1" for="innboks">Flytt:</label>
<div class="col-sm-3">
<select class="input-xlarge form-control" name="innboks" id="innboks">
<option value="2">Ferdig</option>
<option value="1" selected="">Ubehandlet
</option>
<option value="4">Diverse</option>
<option value="3">Arbeidsliste
</option>
</select>
</div>
<label class="control-label col-sm-1" for="tag">Tag:</label>
<div class="col-sm-3">
<select id="tag" class="input-xlarge form-control" name="tag">
<option value="0">-</option>
<option value="1">Morten Andre Pedersen</option>
<option value="2">Richard Hagen</option>
<option value="47">Ola Nordmann</option>
<option value="58">Test Testesen</option>
</select>
</div>
<div class="text-right col-md-3">
<button type="submit" class="btn btn-default">Lagre oppdatering</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
The "Lagre oppdatering" button is displaying as a block element and covers the floating elements to the left (so you can't click them). Changing its style from text-align: right to float: right fixes it. But if you want to display elements below, you're going to need to use clear: both eventually.

How to keep form at centre using bootstrap 2.2.2

In this bootply the welcome as well as the form is coming on the left hand side.But I want to bring it at the centre.Can any body please tell me how to do?
<form id="form1">
<div class="container-fluid">
<div class="row-fluid">
<div class="span1"></div>
<div class="span10" style="margin-bottom: 6px; margin-top: 0px; background: #efeee9">
<img src="ui_resources/img/ title.jpg" alt="" align="left">
<h2 align="center" style="margin-top: 18px;"></h2>
</div>
<div class="span1"></div>
</div>
<div class="row-fluid">
<div class="span1"></div>
<div class="span10" style="background: #eee; border: 1px solid #ddd;">
<div class="span7 center login-header">
<h2 style="color:#E86537 " align="center">Welcome </h2>
</div><!--/span-->
<div class="row-fluid">
<div class="well span7 center login-box">
<div class="alert alert-info">
Please login with your Username and Password.
</div>
<fieldset>
<div class="input-prepend" title="Username" data-rel="tooltip" style="margin-left:80px;">
<span class="add-on"><i class="icon-user"></i></span><input autofocus="" class="input-large span10" name="j_username" id="username" type="text" value="">
</div>
<div class="clearfix"></div>
<div class="input-prepend" title="Password" data-rel="tooltip" style="margin-left:80px;">
<span class="add-on"><i class="icon-lock"></i></span><input class="input-large span10" name="j_password" id="password" type="password" value="">
</div>
<div class="clearfix"></div>
<div class="input-prepend" style="margin-left:80px;">
<label class="remember" for="remember"><input type="checkbox" id="remember" style="display:">Remember me</label>
</div>
<div class="clearfix"></div>
<p class="center span6" style="margin-left:80px;">
<button type="submit" class="btn btn-primary">Login</button>
New Userregister
</p>
</fieldset>
</div><!--/span-->
</div><!--/row-->
</div><!--/row-->
</div>
<div class="span1"></div>
</div></form>
<div class="row-fluid">
<div class="span1"></div>
<div class="span10" style="margin-top: 6px;">
<div class="span1"></div>
</div>
</div>
try to set your welcome div in another div like this
<div class="row-fluid">
<div class="offset3 span6 center login-header">
<h2 style="color:#E86537 " align="center">Welcome </h2>
</div>
</div>
use offset
Move columns to the right using .offset* classes. Each class increases
the left margin of a column by a whole column. For example, .offset4
moves .span4 over four columns.
DEMO
Try using this in your CSS
.row-fluid .login-header,
.row-fluid .login-box{
float:none;
margin:0 auto !important;
}
Since .span* has float: left style by default, you can override it by using float:none;
.login-box {
margin:0 auto;
float:none;
}
margin:0 auto; is used to center your loginbox horizontally.