Putting inputs in a single row - html

NOTE: The markup above is auto-generated by JavaServer Faces.
I have the following markup:
<span style="display: block;">
<input checked="checked" type="checkbox">ID
<select size="1" >
<option value="">Select</option>
<option value="EQUAL" selected="selected">=</option>
</select>
<table style="display: inline-table;">
<tbody>
<tr>
<td>
<input name="cr" value="" type="text">
</td>
</tr>
</tbody>
</table>
</span>
JSFiddle
As we can see from that demo, the inputs is not placed in a row.
How can I place them into a single line as follows:

There are two solutions already, but if you dont want to alter your HTML code, then you can achieve it using some simple css rules. as following fiddle
https://jsfiddle.net/nileshmahaja/5ajmkery/7/
CSS
span *{
display:block;
float:left;
margin-right:5px
}
table{
padding:0;
margin-left:20px;
border-collapse:collapse
}

you have to use table tag in your input???, otherwise you can use
<div>
<input checked="checked" type="checkbox" style="float:left" />
<label style="float:left">ID </label>
<select size="1" style="float:left" >
<option value="" >Select</option>
<option value="EQUAL" selected="selected">=</option>
</select>
<input name="cr" value="" type="text" style="float:left">
</div>
i hope that this solution help you

Im not sure about limitations, but u could add display and margin style to table. It's a bit hacky..
<table style="display: inline-block;margin-bottom: -9px;">
<tbody>
<tr>
<td>
<input name="createRecipientDynamicGroupForm:j_idt240:8:j_idt253" value="" type="text">
</td>
</tr>
</tbody>
</table>

You can try this:
<table style="display: inline-table;">
<tbody>
<tr>
<td>
<input checked="checked" type="checkbox">ID
</td>
<td>
<select size="1" > <option value="">Select</option>
<option value="EQUAL" selected="selected">=</option>
</select>
</td>
<td>
<input name="createRecipientDynamicGroupForm:j_idt240:8:j_idt253" value="" type="text">
</td>
</tr>
</tbody>
</table>
Basically I have moved the 1st 2 elements in the table.

Related

width: 100% and white-space: nowrap results in input elements going over width of parent element

Here's my code:
<table>
<tr>
<td colspan="2" style="white-space: nowrap">Field 1: <input type="text" name="member_name" style="width: 100%"/></td>
<td colspan="2" style="white-space: nowrap">Field 2: <input type="text" name="member_name2" style="width: 100%"/></td>
</tr>
<tr>
<td>Phone: <input type="text" name="phone" /></td>
<td>State: <select name="state">
<option value="TX">Texas</option>
</select></td>
<td>Phone: <input type="text" name="phone2" /></td>
<td>State: <select name="state2">
<option value="TX">Texas</option>
</select></td>
</tr>
</table>
The problem is that the <td> elements with white-space set to nowrap extend into the neighboring <td>'s, presumably because of the width: 100% bit in the child <input>.
Any ideas as to how I can fix this?
You can place a div inside td.
use flex to align the elements.
No need of using white-space and width: 100%
.form-control {
display: flex;
}
.form-control input {
flex-grow: 1;
}
<table>
<tr>
<td colspan="2">
<div class="form-control">
<label>Field 1: </label>
<input type="text" name="member_name"/>
</div>
</td>
<td colspan="2">
<div class="form-control">
<label>Field 2: </label>
<input type="text" name="member_name"/>
</div>
</td>
</tr>
<tr>
<td>Phone: <input type="text" name="phone" /></td>
<td>State: <select name="state">
<option value="TX">Texas</option>
</select></td>
<td>Phone: <input type="text" name="phone2" /></td>
<td>State: <select name="state2">
<option value="TX">Texas</option>
</select></td>
</tr>
</table>

How to make the input text wider

I trying to make the text bar wider but I cant get it to work. I have tried with width but it didn't work for me. I also couldn't find anything on the internet.
This is my HTML:
HTML:
<form action="" method="post">
<legend>Neem contact op</legend>
<table>
<tr>
<td>
<label for="Naam">Naam: </label>
</td>
<td>
<input type="text" id="Naam" name="Naam" placeholder="Naam" required="required" />
</td>
</tr>
<tr>
<td>
<label for="Email">Email :</label>
</td>
<td>
<input type="email" id="Email"name="Email" placeholder="Email" required="required" />
</td>
</tr>
<tr>
<td>
<label for="Seizoen">Seizoen: </label>
</td>
<td>
<select name="Seizoen" id="Seizoen" required>
<option value="">Kies hier je seizoen</option>
<option value="Lente">Lente</option>
<option value="Zomer">Zomer</option>
<option value="Herfst">Herfst</option>
<option value="Winter">Winter</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td>
<label for="Benodigheden">Benodigheden:</label>
</td>
<td>
<input type="text" id="Benodigheden"name="Benodigheden" placeholder="Benodigheden" required="required" />
</td>
</tr>
<tr>
<td>
<label for="Opmerking">Opmerking:</label>
</td>
<td>
<textarea name="Opmerking" id="Opmerking" cols="40" rows="5" placeholder="Opmerking" required="required" /></textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<div class="submit"><input type="submit" value="Verzenden" name="Verzenden" /></div>
</td>
</tr>
</table>
Here is a link to JSFiddle.
While the above code is very good, minimal and clean, which is best. But IF you need different widths for each of your text inputs then inline CSS is needed.
Example code:
<input style="width: 300px;" type="text">
<input style="width: 340px;" type="text">
If you only wish to make input-type="text" have a certain width, add this style in your css file fx:
input[type=text] {
width: 300px;
}
add some css to the head section of your html
<style>
input{width: 300px}
</style>
Make your table wider.
Add desired width to your td's
Ajust your inputs widht.

Align center not working for td in table?

Here is a simple html table with three rows. I want the button in the last row to align at the center but it is not aligning. I can see slight movement to the right but not perfectly at the center of that row. Am i doing something wrong? Thanks for help!
HTML
<div class="search">
<form action="questions/${id}" method="GET">
<table>
<tr>
<td>
<label for="question_id"> <u><b> Question: </b></u>
</label>
</td>
<td>
<input type="text" name="lastname" value="Mouse">
</td>
</tr>
<tr>
<td>
<label for="race_id"> <u><b> Race: </b></u>
</label>
</td>
<td>
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Submit">
</td>
</tr>
</table>
</form>
</div>
CSS
.search table {
border: thin solid;
border-color: #D6D6C2;
}
.search table tr:last-child td {
text-align: center;
}
just assign colspan="2" for td Sample:
<td colspan="2">
<input type="submit" value="Submit">
</td>
Your table has 2 columns. However, the button is only in the left column. That's the reason your buttons aligns to center of only the left column and not to the center of the table.
Setting the colspan to 2 for td of last row will expand the cell to 2 columns (and so to width of the table). Now button in td will align to center of the table.
<td colspan="2">
<input type="submit" value="Submit" />
</td>
Or you can do this also.
.thirdRow
{
text-align:center;
}
<tr>
<td colspan="2">
<input class="thirdRow" type="submit" value="Submit">
</td>
</tr>
You should use COLSPAN=2 or colspan="2" .
<td colspan="2">
<input type="submit" value="Submit">
</td>
See Fiddle here.
That should center it perfectly.
In case you're wondering why your code didn't work:
Basically , the <td> which contains your button is not taking up 100% of the <tr> width , see this Fiddle.
Add this:
<td align="center" colspan="3">
<input type="submit" value="Submit">
</td>

Bottom table row goes to top

I have the following table code that each row contains a form. My problem is, the bottom row, where the input and submit are, is going to the top above the top table row. I cannot figure out why. Can someone please help and explain why the bottom row goes to the very top?
<table id="bet_table" width=800px cellspacing=0 cellpadding=1 border-width=1px>
<tr bgcolor="BF1919" style="color:#fff; font-weight:bold;">
<td><center>Time</center></td>
<td><center>Game #</center></td>
<td><center>Teams</center></td>
<td><center>Run Line</center></td>
<td><center>Money Line</center></td>
<td><center>Total Runs</center></td>
</tr>
<tr bgcolor="#F0F0F0">
<td colspan=6><center><strong>August 28, 2012</strong></center></td>
</tr>
<tr bgcolor="#fff">
<form action="mlb.php?action=update&gameid=" method="post" />
<td width="130px"><center><input type="text" size="4" name="time" value="7:00" />
<select name="ampm">
<option value="AM">A.M.
<option value="PM">P.M.
</select></center></td>
<td width="60px"><center>306</center></td>
<td>Los Angeles Dodgers<br />Los Angeles Angels</td>
<td width="150px"><center>
<select name="runline1frac">
<option value="-1/2">-1½
<option value="+1/2">+1½
</select> <input type="text" size="4" name="runline1value" value="+120" /><br />
<select name="runline2frac">
<option value="-1/2">-1½
<option value="+1/2">+1½
</select> <input type="text" size="4" name="runline2value" value="-182" /></center></td>
<td width="80px"><center><input type="text" size="4" name="moneyline1value" value="-132" /><br /><input type="text" size="4" name="moneyline2value" value="+132" /></center></td>
<td align=right>Total Runs: <input type="text" size="3" name="totalruns" value="6" /> OV <input type="text" size="4" name="totalrunsOvalue" value="-178" /><br />UN <input type="text" size="4" name="totalrunsUvalue" value="+123" /></td>
</tr>
<tr colspan=6>
<center>
<input type="submit" value="Update" />
</form>
</center>
</tr>
</table>
Pasted your code and fixed it here:
http://jsfiddle.net/5nNxB/
Your last <tr> did not have a <td>. Added it with the right colspan.
As a side note, your code is not very clean. Wrap the entire table in <form> instead of randomly inserting the tags in the middle. Also, try not to use inline styling and attributes like bgcolor etc.
Bottom of your code :
<tr colspan=6>
<center>
<input type="submit" value="Update" />
</form>
</center>
</tr>
Should be:
<tr>
<td colspan=6>
<center>
<input type="submit" value="Update" />
</form>
</center>
</td>
</tr>
The form tag also is placed incorrectly

Positioning certain number of divs from left to right and then again from left to right in lower part

I have certain number of dynamically generated #divs with known .className(All have same className) but unknown Id's. I want to make the size (width , height) of the #divs to be fixed and then to show them from left to right, in one row and then to next row if it does not fit in the row. I tried (float : left ) , But the element below the last div, also displays on the left and gives an ugly look + the divs are not in same size(they have variable length of text). What is the css properties and how to set it to do the magic for me....
I am not quiet sure but i think the problem should be solved by some form of positioning (absolute , relative, etc) be defined for the classes.
<html>
<head>
<style>
.wrapperDiv{
overflow:auto;
background-color:green;
position:relative;
}
.column{
background-color:aqua;
width:20em;
height:20em;
float:left;
margin:2px;
}
</style>
</head>
<body>
<form>
<div class="wrapperDiv">
<table class="column">
<tr><td>Name<hr/></td></tr><tr><td>DataType :</td><td><select name="Name_dataType" class="dataType" onchange="typeChanged(this)" ><option value="text" selected="true" > Text </option><option value="number" > Number </option><option value="date" > Date </option></select></td></tr>
<tr><td>Equals:</td><td> <input type="text" name="Name_equals"/></td></tr> <br/><tr><td>Contains:</td><td> <input type="text" name="Name_contains"/></td></tr><br/>
</table>
<table class="column">
<tr><td>Name<hr/></td></tr><tr><td>DataType :</td><td><select name="Name_dataType" class="dataType" onchange="typeChanged(this)" ><option value="text" selected="true" > Text </option><option value="number" > Number </option><option value="date" > Date </option></select></td></tr>
<tr><td>Equals:</td><td> <input type="text" name="Name_equals"/></td></tr> <br/><tr><td>Contains:</td><td> <input type="text" name="Name_contains"/></td></tr><br/>
</table>
<table class="column">
<tr><td>Name<hr/></td></tr><tr><td>DataType :</td><td><select name="Name_dataType" class="dataType" onchange="typeChanged(this)" ><option value="text" selected="true" > Text </option><option value="number" > Number </option><option value="date" > Date </option></select></td></tr>
<tr><td>Equals:</td><td> <input type="text" name="Name_equals"/></td></tr> <br/><tr><td>Contains:</td><td> <input type="text" name="Name_contains"/></td></tr><br/>
</table>
<table class="column">
<tr><td>DATE_OF_BIRTH<hr/></td></tr><tr><td>DataType :</td><td><select name="DATE_OF_BIRTH_dataType" class="dataType" onchange="typeChanged(this)" ><option value="text" > Text </option><option value="number" > Number </option><option value="date" selected="true" > Date </option></select></td></tr>
<tr><td>Equals:</td><td> <input type="text" name="DATE_OF_BIRTH_equals"/></td></tr> <br/><tr><td>Greater_Then:</td><td> <input type="text" name="DATE_OF_BIRTH_greaterThen"/></td></tr><br/><tr><td>Less_Then:</td><td> <input type="text" name="DATE_OF_BIRTH_lessThen"/></td></tr><br/>
</table>
<table class="column">
<tr><td>DATE_OF_BIRTH<hr/></td></tr><tr><td>DataType :</td><td><select name="DATE_OF_BIRTH_dataType" class="dataType" onchange="typeChanged(this)" ><option value="text" > Text </option><option value="number" > Number </option><option value="date" selected="true" > Date </option></select></td></tr>
<tr><td>Equals:</td><td> <input type="text" name="DATE_OF_BIRTH_equals"/></td></tr> <br/><tr><td>Greater_Then:</td><td> <input type="text" name="DATE_OF_BIRTH_greaterThen"/></td></tr><br/><tr><td>Less_Then:</td><td> <input type="text" name="DATE_OF_BIRTH_lessThen"/></td></tr><br/>
</table>
</div>
</form>
</body>
</html>
Why the tables vertical alignment changes from left to right...........
Okay, I see a couple of contradictions in what you want to do.
First: You say you want to make the size of the divs fixed, but afterwards you say the divs do not have the same size as they have variable length of text. You must go for one of the two options. If you have variable text in the divs, you must be aware that you cannot make the div's dimensions fixed unless you want to risk the text overflowing the div. That, or check your text to be sure it fits the divs.
Second: You say you are using float: left, but then complain that the element below the last div (the last of the row, I assume) also displays left. If you want the first div of a row to display at the right, you should use float: right.
I hope this clarifies the issue for you.
Update:
Okay, I found the problem with your code. First of all, let me tell you that you shouldn't use tables for layout. <div> will make your code simpler and are better for that purpose. Anyway, it wasn't that what was breaking your layout. It was some <br/> tags you inserted at the end of the tables for some reason. So your code would look better like this:
<form>
<div class="wrapperDiv">
<table class="column">
<tr>
<td>Name<hr/></td></tr>
<tr>
<td>DataType :</td>
<td>
<select name="Name_dataType" class="dataType" onchange="typeChanged(this)" >
<option value="text" selected="true" > Text </option>
<option value="number" > Number </option>
<option value="date" > Date </option>
</select>
</td>
</tr>
<tr>
<td>Equals:</td>
<td>
<input type="text" name="Name_equals"/>
</td>
</tr>
<tr>
<td>Contains:</td>
<td>
<input type="text" name="Name_contains"/>
</td>
</tr>
</table>
<table class="column">
<tr>
<td>Name<hr/></td>
</tr>
<tr>
<td>DataType :</td>
<td>
<select name="Name_dataType" class="dataType" onchange="typeChanged(this)" >
<option value="text" selected="true" > Text </option>
<option value="number" > Number </option>
<option value="date" > Date </option>
</select>
</td>
</tr>
<tr>
<td>Equals:</td>
<td>
<input type="text" name="Name_equals"/>
</td>
</tr>
<tr>
<td>Contains:</td>
<td>
<input type="text" name="Name_contains"/>
</td>
</tr>
</table>
<table class="column">
<tr>
<td>Name<hr/></td>
</tr>
<tr>
<td>DataType :</td>
<td>
<select name="Name_dataType" class="dataType" onchange="typeChanged(this)" >
<option value="text" selected="true" > Text </option>
<option value="number" > Number </option>
<option value="date" > Date </option>
</select>
</td>
</tr>
<tr>
<td>Equals:</td>
<td>
<input type="text" name="Name_equals"/>
</td>
</tr>
<tr>
<td>Contains:</td>
<td>
<input type="text" name="Name_contains"/>
</td>
</tr>
</table>
<table class="column">
<tr>
<td>DATE_OF_BIRTH<hr/></td>
</tr>
<tr>
<td>DataType :</td>
<td>
<select name="DATE_OF_BIRTH_dataType" class="dataType" onchange="typeChanged(this)" >
<option value="text" > Text </option>
<option value="number" > Number </option>
<option value="date" selected="true" > Date </option>
</select>
</td>
</tr>
<tr>
<td>Equals:</td>
<td>
<input type="text" name="DATE_OF_BIRTH_equals"/>
</td>
</tr>
<tr>
<td>Greater_Then:</td>
<td>
<input type="text" name="DATE_OF_BIRTH_greaterThen"/>
</td>
</tr>
<tr>
<td>Less_Then:</td>
<td>
<input type="text" name="DATE_OF_BIRTH_lessThen"/>
</td>
</tr>
</table>
<table class="column">
<tr>
<td>DATE_OF_BIRTH<hr/></td>
</tr>
<tr>
<td>DataType :</td>
<td>
<select name="DATE_OF_BIRTH_dataType" class="dataType" onchange="typeChanged(this)" >
<option value="text" > Text </option>
<option value="number" > Number </option>
<option value="date" selected="true" > Date </option>
</select>
</td>
</tr>
<tr>
<td>Equals:</td>
<td>
<input type="text" name="DATE_OF_BIRTH_equals"/>
</td>
</tr>
<tr>
<td>Greater_Then:</td>
<td>
<input type="text" name="DATE_OF_BIRTH_greaterThen"/>
</td>
</tr>
<tr>
<td>Less_Then:</td>
<td>
<input type="text" name="DATE_OF_BIRTH_lessThen"/>
</td>
</tr>
</table>
</div>
</form>
You can see it working in a jsfiddle here.