Why textarea higher than text input? - html

Found it, sorry, changed padding and forgot to change it for textarea.
My mistake. Will delete )
I'm trying to make table with text input and textarea input on the same row, but cannot make textarea the same height as the text input.
Could anyone please tell me, why text input and textarea have different height and how to fix that? As you can see, textarea is 2px higher and chrome inspector tells me the same. What's wrong and how to fix that?
(sorry for a large text, site told me that I've got "mostly code" and have to add some details. Have no idea, what else may I add to that code, the problem is obvious)))
Thank you!
div
{
background: #ddd;
}
input#te
{
position: relative;
outline:0;
border: 1px solid #a78;
padding-left: 0.5em;
padding-right: 0.5em;
margin: 0;
background: transparent;
height: 5em;
line-height: 5em;
vertical-align: middle;
}
textarea#ta
{
position: relative;
outline:0;
border: 1px solid #a78;
padding-left: 0.5em;
padding-right: 0.5em;
margin: 0;
background: transparent;
height: 5em;
vertical-align: middle;
resize: none;
}
<table>
<tr>
<td>
<div>
<input type=text id="te" value="input is 2px smaller in chrome">
</div>
</td>
<td>
<div>
<textarea id="ta">textarea is 2px higher in chrome</textarea>
</div>
</td>
</tr>
</table

the textarea has padding top-bottom 2px,
the input only 1px.

change the padding on textarea:
div
{
background: #ddd;
}
input#te
{
position: relative;
outline:0;
border: 1px solid #a78;
padding-left: 0.5em;
padding-right: 0.5em;
margin: 0;
background: transparent;
height: 5em;
line-height: 5em;
vertical-align: middle;
}
textarea#ta
{
position: relative;
outline:0;
border: 1px solid #a78;
padding: 1px 0.5em;
margin: 0;
background: transparent;
height: 5em;
vertical-align: middle;
resize: none;
}
<table>
<tr>
<td>
<div>
<input type=text id="te" value="input is 2px smaller in chrome">
</div>
</td>
<td>
<div>
<textarea id="ta">textarea is 2px higher in chrome</textarea>
</div>
</td>
</tr>
</table

box-sizing: border-box; is what you need to place onto the input and text area. Also works well for select.
By using box-sizing: border-box; it means you dont have to adjust all of your widths, padding and line-height and you can have everything the same
div
{
background: #ddd;
}
input#te
{
position: relative;
outline:0;
border: 1px solid #a78;
padding-left: 0.5em;
padding-right: 0.5em;
margin: 0;
background: transparent;
height: 5em;
line-height: 5em;
vertical-align: middle;
box-sizing: border-box;
}
textarea#ta
{
position: relative;
outline:0;
border: 1px solid #a78;
padding-left: 0.5em;
padding-right: 0.5em;
margin: 0;
background: transparent;
height: 5em;
vertical-align: middle;
resize: none;
box-sizing: border-box;
}
<table>
<tr>
<td>
<div>
<input type=text id="te" value="input is 2px smaller in chrome">
</div>
</td>
<td>
<div>
<textarea id="ta">textarea is 2px higher in chrome</textarea>
</div>
</td>
</tr>
</table

To fix the problem, add box-sizing: border-box to the input element AND to the textarea element (for the fix to work in Chrome).
div {
background: #ddd;
}
input#te {
position: relative;
outline: 0;
border: 1px solid #a78;
padding-left: 0.5em;
padding-right: 0.5em;
margin: 0;
background: transparent;
height: 5em;
line-height: 5em;
vertical-align: middle;
box-sizing: border-box;
}
textarea#ta {
position: relative;
outline: 0;
border: 1px solid #a78;
padding-left: 0.5em;
padding-right: 0.5em;
margin: 0;
background: transparent;
height: 5em;
vertical-align: middle;
resize: none;
box-sizing: border-box;
}
<table>
<tr>
<td>
<div>
<input type=text id="te" value="input is 2px smaller in chrome">
</div>
</td>
<td>
<div>
<textarea id="ta">textarea is 2px higher in chrome</textarea>
</div>
</td>
</tr>
</table>

Related

How to move a text input to the top in a input field?

I've recently started learning Html and Css and I'm trying to move the word "Your Comment" to the top in the input field.
https://prnt.sc/1k74619
<div class="comment">
<input placeholder="Your Comment" type="text" />
</div>
.comment input {
width: 680px;
height: 169;
border: 0;
padding-left: 20px;
font-family: 'Montserrat';
outline-color: #b5b5b5;
margin-top: 30px;
margin-left: -115px;
}
<INPUT> tag is for single line text but <TEXTAREA></TEXTAREA> tag is for multi line text.
Useful link: https://www.w3schools.com/html/html_form_elements.asp
*{
box-sizing: border-box;
}
.comment input,
.comment textarea{
font-family: 'Montserrat', Arial;
width: 100%;
max-width: 680px;
padding: 20px;
border: 1px solid #b5b5b5;
outline: none;
border-radius: 8px;
margin-bottom: 10px;
}
.comment textarea{
height: 169px;
}
.comment input:focus,
.comment textarea:focus{
border: 1px solid #32babe;
box-shadow: 0 0 0 2px #32babe;
}
<div class="comment">
<input type="text" placeholder="Your Commnet - in single line">
<textarea placeholder="Your Comment - in multi lines"></textarea>
</div>
I don't think this is possible to do, if you want a larger multi line text input area <textarea></textarea> may suit your needs.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
If you want to achieve the same effect you can try nesting the input field in a bordered <div> something like this perhaps:
https://codepen.io/iltg/pen/RwVemeB
You can do like this:
textarea {
font-size: .8rem;
letter-spacing: 1px;
}
textarea {
padding: 10px;
max-width: 100%;
line-height: 1.5;
border-radius: 5px;
border: 1px solid #ccc;
box-shadow: 1px 1px 1px #999;
}
<textarea id="story" name="story"
rows="5" cols="33">
Your comment
</textarea>
You can use Bootstrap's floating label. It would do the job very nicely.
Here's how you will do it:
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea"></textarea>
<label for="floatingTextarea">Comments</label>
</div>
.custom-field{
position: relative;
margin-top: 50px;
}
.comment input, .comment textarea {
font-family: 'Montserrat', Arial;
width: 100%;
max-width: 680px;
padding: 20px;
border: 1px solid #b5b5b5;
outline: none;
border-radius: 8px;
margin-bottom: 0;
}
.placeholder {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
}
.custom-field input:focus + .placeholder {
top: -20px;
}
<div class="custom-field">
<input id="email-field" type="email">
<label for="email-field" class="placeholder">Enter Email</label>
</div>

div table cell width totally ignored

As per title, cell width is totally ignored - tried so many things and none work. Tried inspecting to see if there is any inheritance that i do not know about but nothing showed up. The cells just split into equal chunks and cell width property is ignored.
.CalculateBtn {
background-color: #96c11f;
width: 200px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
display: inline-block;
cursor: pointer;
color: #ffffff;
font-family: Raleway, Arial;
font-size: 21px;
font-weight: normal;
padding: 10px 10px;
text-decoration: none;
text-align: center;
}
.CalculateBtn:hover {
background-color: #7f0050;
color: #ffffff;
}
.divTable {
display: table;
width: 100%;
table-layout: fixed;
/*vertical-align: top;*/
}
.divTableRow {
display: table-row;
background-color: #0d56c2;
}
.divTableButtonRow {
display: table-row;
}
.divTableHead-left {
background-color: #7F0050;
display: table-cell;
padding: 3px 10px;
width: 30%;
}
.divTableHead-center {
color: #ffffff;
text-align: center;
font-family: raleway, arial, helvetica, sans-serif;
background-color: #7F0050;
display: table-cell;
padding: 3px 10px;
width: 40%;
}
.divTableHead-right {
background-color: #7F0050;
display: table-cell;
padding: 3px 10px;
width: 30%;
}
/* Table Cells */
.divTableCell-left,
.divTableHead {
border-right: 1px solid #ffffff;
border-top: 1px solid #ffffff;
display: table-cell;
padding: 3px 10px;
width: 20%;
}
.divTableCell-center,
.divTableHead {
border-right: 1px solid #ffffff;
border-top: 1px solid #ffffff;
display: table-cell;
padding: 3px 10px;
width: 30%;
color: #ffffff;
}
.divTableCell-right,
.divTableHead {
border-right: 1px solid #ffffff;
border-top: 1px solid #ffffff;
display: table-cell;
padding: 3px 10px;
width: 50%;
color: #ffffff;
}
/* Button Cell properties */
.divTableCellButton-left,
.divTableHead {
display: table-cell;
padding: 3px 10px;
width: 30%;
}
.divTableCellButton-center,
.divTableHead {
display: table-cell;
padding: 3px 10px;
width: 40%;
}
.divTableCellButton-right,
.divTableHead {
display: table-cell;
padding: 3px 10px;
width: 30%;
}
/* End Button Cell properties */
/* INFO cell properties*/
.divTableCellInfo-left {
color: #ffffff;
display: table-cell;
padding: 3px 10px;
max-width: 20%;
}
.divTableCellInfo-right {
color: #ffffff;
display: table-cell;
padding: 3px 10px;
max-width: 80%;
}
/* End info cell properties*/
.divTableFoot {
background-color: #EEE;
display: table-footer-group;
font-weight: bold;
}
.divTableBody {
display: table-row-group;
}
<div class="divTable" style="border: 1px solid #ffffff;">
<div class="divTableBody">
<div class="divTableHead-left"> </div>
<div class="divTableHead-center">
<font size="4">Staffing Calculator K=2</font>
</div>
<div class="divTableHead-right"> </div>
<div class="divTableRow">
<div class="divTableCell-left">
<font color="#ffffff">Calls:</font>
</div>
<div class="divTableCell-center"><input type="text" name="calls" id="calls" style="width: 80px;" value="151"></div>
<div class="divTableCell-right">
<font color="#ffffff">in a period of</font>
<input name="period" value="5" />
<select name="callUnit">
<option value="hour" selected>hours</option>
<option value="minute" >minutes</option>
</select>
</div>
</div>
<div class="divTableRow">
<div class="divTableCell-left">
<font color="#ffffff">Average Handle Time: </font>
</div>
<div class="divTableCell-center"><input type="text" name="aht" value="300"></div>
<div class="divTableCell-right">
<select name="ahtUnit">
<option value="minute" >minutes</option>
<option value="second" selected>seconds</option>
</select> <i>include time spent on phone and time working after call. Usually between 3 and 5 minutes.</i>
</div>
</div>
</div>
I use colgroup for this. I see you are using div's in your markup and table related CSS to style your table, so my suggestion would require that you change your markup to table markup (not sure if doable).
table {
width: 100%;
table-layout: fixed;
}
th {
background: #0095ff;
color: white;
}
td {
border: 1px solid #ccc;
}
<table>
<colgroup>
<col style="width:30%" />
<col style="width:40%" />
<col style="width:30%" />
</colgroup>
<thead>
<tr>
<th colspan="3">This is the table header</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
</tr>
</tbody>
</table>

Html table tag not properly display when text inside is longer than other

I have been try to make an html and css lines to display user image, name, old file name, new file name and date.
My problem is when the whole content has the same length it will look good but if the username is longer or another other sting is longer it will deform the table and design please i need help.
Below is a sample image and jsfiddle link
Here is bad side
Here is my html code
<table>
<tr class="treeFile">
<td>
<img src="Pictures/b78d7cd4555821042a70d9ec034b0dea.PNG" alt="Front" class="treeimage"/>
<span class="treposition" align="center">
<span class="treeSenderline"><span class="treeName">Ujah peter</span></span>
<span class="treeSenderXXX"></span>
</span>
</td>
<td width="1px"></td>
<td align="center">
<div class="treeMain">
<span class="fromtree"><strong>Mainprojectarea</strong></span>
<span><strong>Newprojectarea</strong></span>
<span class="treeBottomLine">10-28-2016</span>
</div>
</td>
</tr>
<tr class="treeFile">
<td>
<img src="Pictures/b78d7cd4555821042a70d9ec034b0dea.PNG" alt="Front" class="treeimage"/>
<span class="treposition" align="center">
<span class="treeSenderline"><span class="treeName">micheal grayer</span></span>
<span class="treeSenderXXX"></span>
</span>
</td>
<td width="1px"></td>
<td align="center">
<div class="treeMain">
<span class="fromtree"><strong>Mainprojectareaxxx</strong></span>
<span><strong>Newprojectlocation</strong></span>
<span class="treeBottomLine">10-28-2016</span>
</div>
</td>
</tr>
</table>
Here is css code
.treeBottomLine{
border-bottom: 2px solid #337ab7;
display: block;
margin-top: 0px;
width: 60%;
height: 20px;
text-align: center;
align-content: center;
border-left: 2px solid #337ab7;
border-right: 2px solid #337ab7;
background-color: #fff;
}
.fromtree{
display: inline-block;
border-bottom: 2px solid #337ab7;
border-left: 2px solid #337ab7;
border-right: 2px solid #337ab7;
padding: 3px;
margin-right: 3em;
background-color: #fff;
}
.treeimage{
border-radius: 50%;
border: 2px solid #337ab7;
background-color: #fff;
margin: 5px;
margin-right: 1em;
width:30px;
height:30px;
}
.treeName{
border: 2px solid #337ab7;
background-color: #fff;
padding: 3px;
margin-left: 2em;
margin-right: auto;
text-align: center;
display: inline-block;
}
.treeSender{
border-top: 2px solid #337ab7;
width: 100%;
display: inline-block;
position: relative;
top: -2.6em;
left: 33px;
z-index: 0;
}
.treeSenderline{
display: inline-block;
position: relative;
left: 2.6em;
top: -2em;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
background-color: #337ab7;
width: 100%;
height: 3px;
}
.treeMain{
position: relative;
}
Here is a link to https://jsfiddle.net/evr50w05/
I believe what you're looking for is to float the blue line to the left, and add a margin:
.treeMain {
float: left;
margin-left: 33px;
}
I've created a fiddle showcasing this here.
Hope this helps!

Center two lis inside ul horizontally

I have two lis inside a ul. And I'm not able to make the lis center.
I can center the li by giving fixed width to it. Can it be done without giving fixed width?
.PhNumber_email_list {
display: inline-block;
clear: both;
padding: 10px 0px;
width: 100%;
margin: 0 auto;
max-width: 700px;
border: 2px solid black;
}
.PhNumber_email_list li {
list-style: none;
float: left;
margin: 5px 20px;
position: relative;
}
.PhNumber_email_list li input {
border: 2px solid #196edf;
width: 100%;
padding: 15px 5px;
color: #3f3f3f;
text-align: center;
font-weight: 700;
}
<ul class="PhNumber_email_list">
<li>
<input type="text" placeholder="Email">
<p class="hint">Your email is kept private and secure</p>
</li>
<li>
<input type="text" class="PhNumber_mask" placeholder="Phone Number (Optional)">
<p class="hint">Get exclusive support</p>
</li>
</ul>
Heres the fiddle
demo - http://jsfiddle.net/99stwpnp/3/
use box-sizing:border-box for input so that the padding is calculated from inside
and instead of float:left use display:inline-block so that you center it without giving width
.PhNumber_email_list {
display: inline-block;
clear: both;
text-align: center;
padding: 10px 0px;
width: 100%;
margin: 0 auto;
max-width: 700px;
border: 2px solid black;
}
.PhNumber_email_list li {
list-style: none;
display: inline-block;
margin: 5px 20px;
position: relative;
}
.PhNumber_email_list li input {
border: 2px solid #196edf;
width: 100%;
box-sizing: border-box;
padding: 15px 5px;
color: #3f3f3f;
text-align: center;
font-weight: 700;
}
<ul class="PhNumber_email_list">
<li>
<input type="text" placeholder="Email">
<p class="hint">Your email is kept private and secure</p>
</li>
<li>
<input type="text" class="PhNumber_mask" placeholder="Phone Number (Optional)">
<p class="hint">Get exclusive support</p>
</li>
</ul>
If using a percentage for the width of the <li> is ok I think you can. In the following example I've added box-sizing: border-box to the li and the li input to include the padding and the border size in the width. I've added a width: 50% to the li and changed the margin into a padding.
.PhNumber_email_list {
display: inline-block;
padding: 10px 0px;
width: 100%;
margin: 0 auto;
max-width: 700px;
border: 2px solid black;
}
.PhNumber_email_list li {
box-sizing: border-box;
list-style: none;
float: left;
padding: 5px 20px;
width: 50%;
}
.PhNumber_email_list li input {
box-sizing: border-box;
border: 2px solid #196edf;
width: 100%;
padding: 15px 5px;
color: #3f3f3f;
text-align: center;
font-weight: 700;
}
<ul class="PhNumber_email_list">
<li>
<input type="text" placeholder="Email">
<p class="hint">Your email is kept private and secure</p>
</li>
<li>
<input type="text" class="PhNumber_mask" placeholder="Phone Number (Optional)">
<p class="hint">Get exclusive support</p>
</li>
</ul>

how to achieve following using css ( digits input )

I am trying to achieve following feature:
It's an input box, has 4 digits, once clicked, user can input 4 digits.
It's part of a mobile app.
Currently what I have achieved is : example, note that for some reason,
outline: none; works fine in my app but not work in this jsFiddle example.
My question is how to draw the 3 separation bar and also display those digits
just fit their position within it?
Is it achievable using css?
below are code:
<form id="login" class="ui-shadow-around ui-corner-all-input" data-enhance="false">
<div data-role="fieldcontain">
<span>
<input type="tel" name="retailer_pin" maxlength="4" class="numbersOnly" required="" placeholder="" style="outline: none;">
</span>
</div>
<input type="submit" class="submitHidden">
</form>
css:
.ui-corner-all-input {
-webkit-background-clip: padding;
background-clip: padding-box;
-webkit-border-radius: .6em /*{global-radii-blocks}*/;
border-radius: .6em /*{global-radii-blocks}*/;
width: 35%;height: 3.5em; margin: 0 auto; margin-bottom: 44px;
margin-top: 24px;
}
.ui-shadow-around {
-moz-box-shadow: 0px 0px 4px /*{global-box-shadow-size}*/ rgba(0,0,0,0.4) /*{global-box-shadow-color}*/;
-webkit-box-shadow: 0px 0px 4px /*{global-box-shadow-size}*/ rgba(0,0,0,0.4) /*{global-box-shadow-color}*/;
box-shadow: 0px 0px 4px /*{global-box-shadow-size}*/ rgba(0,0,0,0.4) /*{global-box-shadow-color}*/;
border: 1px #b6b6b6 solid;
}
*:not(input):not(textarea) {
-webkit-user-select: none;
-webkit-touch-callout: none;
}
FORM[data-enhance="false"] INPUT, textarea {
outline: none;
}
FORM[data-enhance="false"] SPAN {
overflow: hidden;
display: block;
padding: 0 10px 0 0px;
text-align: left;
}
.submitHidden {
visiblity: hidden;
position: absolute;
opacity: 0;
}
Here is my take on the problem.
It uses a proper input element (please don't make the life of your users harder than it already is) and a transparent background to render 4 blocks in the background.
.input-widget {
vertical-align: top;
margin-left: 1rem;
font-size: 2rem;
display: inline-block;
position: relative;
}
.input-widget .input {
width: 8rem;
font-size: inherit;
font-family: inherit;
letter-spacing: 5px;
background-color: transparent;
border: none;
-moz-appearance: textfield;
}
.input-widget .input::-webkit-inner-spin-button,
.input-widget .input::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.input-widget .digit-background {
position: absolute;
top: 1px;
left: 0;
z-index: -1;
}
.input-widget .digit-background .digit {
display: inline-block;
float: left;
}
.input-widget .digit-background .digit::before {
content: '0';
color: lightgray;
background-color: currentColor;
display: inline-block;
padding: 1px;
margin: -1px 4px 0 -1px;
}
<div class="input-widget">
<input type="number" max="9999" class="input" value="01234">
<div class="digit-background">
<div class="digit"></div>
<div class="digit"></div>
<div class="digit"></div>
<div class="digit"></div>
</div>
</div>
And a SCSS version is here: https://jsfiddle.net/cburgmer/0xgtdyLj/1/
You could do it like this:
HTML:
<table>
<tr>
<td><input class="clock" type="text" maxlength="1" size="1" onkeyup="next(2)"></td>
<td><input id="2" class="clock" type="text" maxlength="1" size="1" onkeyup="next(3)"></td>
<td><input id="3" class="clock" type="text" maxlength="1" size="1" onkeyup="next(4)"></td>
<td><input id="4" class="clock" type="text" maxlength="1" size="1"></td>
</tr>
CSS:
.clock {
color:darkgray;
border-style:none;
width:40px;
height:60px;
font-size:60px;
}
td{
border:2px solid darkgray
}
table {
border-collapse:collapse;
}
JavaScript:
function next(next) {
document.getElementById(next).focus();
}
Link: http://jsbin.com/uhaHunuq/1/edit?html,output
Maybe you can use four text input items and put them in a small table. With JavaScript, make each text box take one character and give the focus state to the next text box. The lines could be done with the table border and box. Use the CSS to hide the text box frame.