Vertical-alignment of inline-block elements inside a block element - vertical-alignment

Please find my fiddle here, I'm trying to understand the logic behind the vertical-alignment of the inline-block elements (div.lbl) within div.panel.
<style>
label, .lbl {
width:292px;
display:inline-block;
/* text-align:left; */
}
.val {
display:block;
}
.panel {
border-bottom: 1px dashed red;
}
.lbl {
color: magenta;
}
label {
color:black;
}
</style>
<div class="panel">
<div class="lbl" for="firstname">First name:
<INPUT class="val" type="text" id="firstname" />
</div>
<div class="lbl" for="description">Long field name Long field name Long field name Long field name Long field name Long field name Long field name:
<textarea rows="5" cols="25" class="val" id="description" ></textarea>
</div>
<div class="lbl" for="lastname">Long Last name Long Last name Long Last name
<INPUT class="val" type="text" id="lastname" />
</div>
</div>
<div class="panel">
<div class="lbl" for="firstname1">Long First name Long First :
<INPUT class="val" type="text" id="firstname1" />
</div>
<div class="lbl">First name:
<textarea rows="5" cols="25" class="val" id="description1"></textarea>
</div>
<div class="lbl">Long field name Long field name Long field name Long field name Long field name:
<fieldset class="bank-address">
<label for="address1">Bank Address Line 1</label>
<input type="text" value="" id="address1" name="address1" maxlength="9" />
<label for="address1">Bank Address Line 2</label>
<input type="text" value="" id="address2" name="address2" maxlength="9" />
<label for="address1">Bank Address Line 3</label>
<input type="text" value="" id="address3" name="address3" maxlength="9" />
<label for="address1">Bank Address Line 4</label>
<input type="text" value="" id="address4" name="address4" maxlength="9" />
</fieldset>
</div>
</div>
If you notice, all label texts (in magenta) are vertically aligned bottom and their respective field elements are vertically aligned top such that the bottom of the texts are aligned in same line and the top of the field elements seem to have aligned in the same line. (Click here to see the display of the fiddle page) This is the alignment I'm trying to achieve and works in Firefox, Chrome & Safari. But looks different in all IEs.
In IE, it seems all div.lbl to have vertical-aligned bottom.
Is there a way I can bring the same effect in IE too ?
Thanks.

You can get the effect you want by adding a div element around the input boxes and then setting the elements with class "val" to float:left. Also do the same for the fieldset and give it class "val".
The added div causes the input elements to start on a new line, and the float takes the input element out of the flow, leaving the last line of text in each inline-block box to be used as the baseline for that box.
See http://jsfiddle.net/DaZWW/

Related

Textarea value?

When I use a text-input type , i can just give it a value and use that, even on another page
example:
<input type="text" class="form-control" name="name" value="<?php echo $row['name'];?>">
Can I do the same with a textarea?
example :
<textarea class="form-control" rows="3" cols="123" name="comments" value="<?php echo $row['comments'];?>" ></textarea>
This is my code in where I retrieve an existing row of information from a given ID. The info consists of a name, emailaddress and comments :
<form method="post">
<div class="row gy-2 text-left">
<div class="row">
<div class="col-auto gy-2">
<label>Name</label> <br>
<input type="text" class="form-control" name="name" value="<?php echo $row['naam'];?>">
</div>
</div>
<div class="row">
<div class="col-auto gy-2">
<label>Email address</label><br>
<input type="email" class="form-control" name="email" value="<?php echo $row['email'];?>">
</div>
</div>
<div class="row">
<div class="col-auto gy-2">
<label>Tell me about it</label><br>
<style>
textarea {resize: none;}
</style>
<textarea class="form-control" rows="3" cols="123" name="comments" value="<?php echo $row['comments'];?>" ></textarea>
</div>
<div class="row">
<div class="col-auto gy-3">
<button class="btn edit btn-info border border-dark" name="Update">Update</button>
</div>
</div>
</div>
</form>
For the textarea element, it goes between <textarea> and </textarea> tags:
<textarea><?php echo $row['comments'];?></textarea>
The <textarea> element does not use an HTML attribute named value like the <input> element does.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attributes
However, when the HTML markup which contains a textarea element is parsed by the browser, an HTMLTextAreaElement object is created. This DOM element object, which represents the state of the textarea element on the web page does have a JavaScript object property named .value, which gives access via JavaScript to the text which the textarea element contains.
This JavaScript code logs the text that is contained in a textarea element:
console.info(document.querySelector('textarea').value);
https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement

Give a Style Class for Primefaces Generated span element

Primefaces password control generates a span element and an input text element when HTML is created. How can we give a class for such generated span element?
JSF Code
<p:password id="pwd"
toggleMask="true"
value="#{webUserController.password}"
class="form-control w-100" >
</p:password>
Generated HTML
<span class="ui-password ui-password-masked ui-inputwrapper ui-input-icon-right ui-inputwrapper-filled">
<input id="j_idt603:j_idt608:pwd" name="j_idt603:j_idt608:pwd" type="password" class="ui-inputfield ui-widget ui-state-default ui-corner-all form-control w-100 ui-state-filled" aria-disabled="false">
<i id="j_idt603:j_idt608:pwd_mask" class="ui-password-icon"></i>
</span>
How can I give a style class to the generated span element?
It looks like you are trying to get the field to be 100% wide. You could use PrimeFlex to do this by wrapping your p:password with <div class="field"> (p-field if you are on PrimeFlex 2), so:
<div class="field">
<p:outputLabel for="#next" .../>
<p:password .../>
</div>
See:
https://www.primefaces.org/primeflex/formlayout

<h:form> appears in a new line [duplicate]

This is probably a basic html/css question...
I have a simple one-button form that I would like to display inline inside paragraph text.
<p>Read this sentence
<form style='display:inline;'>
<input style='display:inline;'
type='submit'
value='or push this button'/>
</form>.
</p>
Even though form has style=display:inline attribute, I get a linebreak before the form. Is there a way to get rid of it?
Can form elements appear inside <p>?
Move your form tag just outside the paragraph and set margins / padding to zero:
<form style="margin: 0; padding: 0;">
<p>
Read this sentence
<input style="display: inline;" type="submit" value="or push this button" />
</p>
</form>
<form> cannot go inside <p>, no. The browser is going to abruptly close your <p> element when it hits the opening <form> tag as it tries to handle what it thinks is an unclosed paragraph element:
<p>Read this sentence
</p><form style='display:inline;'>
You can try this code:
<form action="#" method="get" id="login" style=" display:inline!important;">
<label for='User'>User:</label>
<input type='text' name='User' id='User'>
<label for='password'>Password:</label><input type='password' name='password' id='password'>
<input type="submit" name="log" id="log" class="botton" value="Login" />
</form>
The important thing to note is the css style property in the <form> tag.
display:inline!important;
According to HTML spec both <form> and <p> are block elements and you cannot nest them. Maybe replacing the <p> with <span> would work for you?
EDIT:
Sorry. I was to quick in my wording. The <p> element doesn't allow any block content within - as specified by HTML spec for paragraphs.
Add a inline wrapper.
<div style='display:flex'>
<form>
<p>Read this sentence</p>
<input type='submit' value='or push this button' />
</form>
<div>
<p>Message here</p>
</div>
You can accomplish what you want, I think, simply by including the submit button within the paragraph:
<pre>
<p>Read this sentence <input type='submit' value='or push this button'/></p>
</pre>
Just use the style float: left in this way:
<p style="float: left"> Lorem Ipsum </p>
<form style="float: left">
<input type='submit'/>
</form>
<p style="float: left"> Lorem Ipsum </p>

how to customise input field width in bootstrap 3

After having removed critical features such as input-xlarge and input-large, what is the substitution for it in bootstrap 3?
Of course I could use col-lg-12 etc but that is giving an error in tab pane.
I could also use style = "width:30px;" but then It would loose its responsiveness unlike input-xlarge.Any suggestions etc?
In Bootstrap 3, .form-control (the class you give your inputs) has a width of 100%, which allows you to wrap them into col-lg-X divs for arrangement. Example from the docs:
<div class="row">
<div class="col-lg-2">
<input type="text" class="form-control" placeholder=".col-lg-2">
</div>
<div class="col-lg-3">
<input type="text" class="form-control" placeholder=".col-lg-3">
</div>
<div class="col-lg-4">
<input type="text" class="form-control" placeholder=".col-lg-4">
</div>
</div>
See under Column sizing.
It's a bit different than in Bootstrap 2.3.2, but you get used to it quickly.
You can use these classes
input-lg
input
and
input-sm
for input fields and replace input with btn for buttons.
Check this documentation http://getbootstrap.com/getting-started/#migration
This will change only height of the element, to reduce the width you have to use grid system classes like col-xs-* col-md-* col-lg-*.
Example col-md-3. See doc here http://getbootstrap.com/css/#grid
<form role="form">
<div class="form-group">
<div class="col-xs-2">
<label for="ex1">col-xs-2</label>
<input class="form-control" id="ex1" type="text">
</div>
<div class="col-xs-3">
<label for="ex2">col-xs-3</label>
<input class="form-control" id="ex2" type="text">
</div>
<div class="col-xs-4">
<label for="ex3">col-xs-4</label>
<input class="form-control" id="ex3" type="text">
</div>
</div>
</form>
i solved with a max-width in my main css-file.
/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
}
It's a simple solution with little "code"
<div class="form-group">
<div class="input-group col-md-5">
<div class="input-group-addon">
<span class="glyphicon glyphicon-envelope"></span>
</div>
<input class="form-control" type="text" name="text" placeholder="Enter Your Email Id" width="50px">
</div>
<input type="button" name="SIGNUP" value="SIGNUP">
</div>

jQuery UI Radio Button set line Breaks

when I am using two button sets, they do not display on same line. Is there a way to display both of these on the same line? Here is my code
html:
<div id="view">
<input type="radio" id="radio1" name="radio" /><label for="radio1">Regular</label>
<input type="radio" id="radio2" name="radio" checked="checked" /><label for="radio2">Investments</label>
<input type="radio" id="radio3" name="radio" /><label for="radio3">All</label>
</div>
<div id="lod">
<input type="radio" id="lod_S" name="radio" checked="checked" /><label for="radio2">Summary</label>
<input type="radio" id="lod_D" name="radio" /><label for="radio3">Detail</label>
</div>
javascript:
$('#view,#lod').buttonset();
Thanks in advance for the help.
The default styling for div elements causes one to be below the other. You can substitute span here.
jsFiddle
Or use CSS to change the styling of your divs:
<style type="text/css">
#view, #lod {
display: inline;
}
</style>

Resources