Here's the jsFiddle.
Here's the code :
<table>
<tr>
<td id="td00" rowspan="2">
<textarea>A very1 </textarea>
</td>
<td id="td01">
<textarea>A very2 </textarea>
</td>
</tr>
<tr>
<!--td>
<textarea>A very3 </textarea>
</td-->
<td>
<textarea>A very4 </textarea>
</td>
</tr>
</table>
The css :
table, td
{
border:1px solid black;
}
table
{
height:400px;
width:400px;
table-layout:fixed;
}
#td01, #td00
{
height:100%;
}
When I am changing the textarea inside cell with row = 0 and col = 0 the cell with row = 1 and col 1 is changing too.
I need fixing size of cells.
This is not perfect, but i think it will do what you want, you have to set an fixed position to the td and a fixed height so i don't know if you'r ok with that for your project.
HTML:
<table>
<tr>
<td id="td00" rowspan="2">
<textarea>A very1 </textarea>
</td>
<td id="td01">
<textarea>A very2 </textarea>
</td>
</tr>
<tr style="position:fixed;">
<!--td>
<textarea>A very3 </textarea>
</td-->
<td >
<textarea>A very4 </textarea>
</td>
</tr>
</table>
CSS:
table, td{
border:1px solid black;
}
table {
height:400px;
width:400px;
table-layout:fixed;
}
#td01
{
height:320px;
}
EXAMPLE: FIDDLE
Related
I want to make the gif photo to be same width(6 inches)as the table with following css code.
table {
border-collapse: collapse;
}
td {
border: 1px solid red;
width: 2in;
}
div {
text-indent: 2em;
background: url(title_bg.gif) left;
width: 6in;
}
<!DOCTYPE html5>
<header>
<meta charset="utf-8" />
</header>
<body>
<br />
<br />
<div>result</div>
<table>
<tr>
<td>
experiment project
</td>
<td>
unit
</td>
<td>
value
</td>
</tr>
<tr>
<td>
experiment project1
</td>
<td>
unit
</td>
<td>
value
</td>
</tr>
<tr>
<td>
experiment project2
</td>
<td>
unit
</td>
<td>
value
</td>
</tr>
</table>
</body>
</html>
The title_bg.gif is
The output is as the following:
I have set the image to be 6 in ,and three tds here ,3*2=6.
Why the table is larger than the image?
How to make them equal width?
Its because of 1px border and default padding which is 1px if you remove the border and make padding 0 then the result is-
table
{
border-collapse:collapse;
}
td {
/*border:1px solid red;*/
background:#ccc;
width:2in;
padding:0;
}
div {
text-indent:2em;
background: url('https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRn211PPwWEdhmVO4YK4y5ITrIvOUW3bWKHRMsbCZYRLdbkoYPj') left ;
width:6in;
}
<div> result </div>
<table>
<tr>
<td>
experiment project
</td>
<td>
unit
</td>
<td>
value
</td>
</tr>
<tr>
<td>
experiment project1
</td>
<td>
unit
</td>
<td>
value
</td>
</tr>
<tr>
<td>
experiment project2
</td>
<td>
unit
</td>
<td>
value
</td>
</tr>
</table>
Calc() can be useful for you in this condition.
table
{
border-collapse:collapse;
}
td {
border:1px solid red;
background:gray;
width:2in;
padding:0;
}
div {
text-indent:2em;
background:url(yourimagepath.gif)left ;
width:calc(6in + 4px);
}
Note: - see the browser support for calc().
The default behaviour of most browsers is to exclude an element's border-width from the calculation of its width. This means your td's total width (width + border) will be 2in + 2 * 1px. To fix this you can set box-sizing: border-box;
More info here : https://css-tricks.com/box-sizing/
just give the table the same width of div
table{
width:6in;
}
I want the cell align center , but keep text right align. for detail please run the code.
table{border:solid ; width:100%}
th{text-align:center}
td{text-align:center}
<div>now my table show like this</div>
<table>
<tr><th>hello</th><th>world</th><th>jasper</th></tr>
<tr><td>123</td><td>456</td><td>789</td></tr>
<tr><td>1231</td><td>4561</td><td>7891</td></tr>
<tr><td>12312</td><td>45612</td><td>78912</td></tr>
</table>
<br>
<div>but i want to like this</div>
<table>
<tr><th>hello</th><th>world</th><th>jasper</th></tr>
<tr><td> 123</td><td> 456</td><td> 789</td></tr>
<tr><td> 1231</td><td> 4561</td><td> 7891</td></tr>
<tr><td>12312</td><td>45612</td><td>78912</td></tr>
</table>
i solve it with add more th and td but it work Correctly
code
table{border:solid ; width:100%}
th{text-align:center}
td{text-align:right}
#td{
width: 20px;
}
<div>now my table show like this</div>
<table>
<tr><th> </th><th id="td">hello</th><th> </th><th id="td">world</th><th> </th><th id="td">jasper</th><th> </th></tr>
<tr><td> </td><td id="td">123</td><td> </td><td id="td">456</td><td> </td><td id="td">789</td><td> </td></tr>
<tr><td> </td><td id="td">1231</td><td> </td><td id="td">4561</td><td> </td><td id="td">7891</td><td> </td></tr>
<tr><td> </td><td id="td">12312</td><td> </td><td id="td">45612</td><td> </td><td id="td">78912</td><td> </td></tr>
http://liveweave.com/6EFpKY
One solution is to add a div inside th th and td elements and give them a fixed length.
HTML:
<table>
<tr>
<th>
<div>hello</div>
</th>
<th>
<div>world</div>
</th>
<th>
<div>jasper</div>
</th>
</tr>
<tr>
<td>
<div>123</div>
</td>
<td>
<div>456</div>
</td>
<td>
<div>789</div>
</td>
</tr>
<tr>
<td>
<div>1231</div>
</td>
<td>
<div>4561</div>
</td>
<td>
<div>7891</div>
</td>
</tr>
<tr>
<td>
<div>12312</div>
</td>
<td>
<div>45612</div>
</td>
<td>
<div>78912</div>
</td>
</tr>
</table>
CSS:
table {
border:solid;
width:100%
}
td div {
width:40px;
text-align:right;
margin-left: auto;
margin-right: auto;
}
th div {
width:40px;
text-align:right;
margin-left: auto;
margin-right: auto;
}
Try it out:
http://fiddle.jshell.net/hdgjnuab/1/
Hope it helps!
Change your CSS and HTML table code with below one.
CSS:
table{border:solid ; width:100%}
th{text-align:center}
td{direction:rtl;}
.title {margin-right:46%;}
HTML:
<table>
<tr><th>hello</th><th>world</th><th>jasper</th></tr>
<tr>
<td><span class="title">123</span></td>
<td><span class="title">456</span></td><td><span class="title">789</span></td></tr>
<tr><td><span class="title">1231</span></td><td><span class="title">4561</span></td><td><span class="title">7891</span></td></tr>
<tr><td><span class="title">12312</span></td><td><span class="title">45612</span></td><td><span class="title">78912</span></td></tr>
</table>
Output:
No need to define fix width of table cells.
I have a scenario where one table had some tr and other table have less tr's than first one table.Both tables are under td's. In this Scenerio how to increase only last tr height of html table in % mode not in px mode
HTML CODE:
<table border="1" style="width:100%">
<tr>
<td style="width:50%">
<table border="1" style="width:100%">
<tr>
<td>
A
</td>
</tr>
<tr>
<td>
B
</td>
</tr>
<tr>
<td>
C
</td>
</tr>
</table>
</td>
<td style="vertical-align:top">
<table border="1" style="width:100%;">
<tr>
<td>
1
</td>
</tr>
<tr>
<td>
2
</td>
</tr>
</table>
</td>
</tr>
jsfiddle Demo
Try like this: Demo This will expand only last row of right side content
CSS:
table {
height: 100%;
width: 100%;
}
td {
}
.table {
display: table;
height:100%;
}
.cell {
vertical-align: top;
display: table-cell;
height:100%;
}
.container {
height: 100%;
-moz-box-sizing: border-box;
}
HTML:
<table border="1" style="width:100%;" class="table">
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td class="cell">
<div class="container">Increse this row height till parents td height</div>
</td>
</tr>
</table>
EDIT: If you want right column should be equally expanded, you can use like this: Demo
CSS:
table {
height: 100%;
width: 100%;
}
Hope this is what you want!!
use single table and rowspan
<table border="1" style="width:100%">
<tr><td>A</td><td>1</td></tr>
<tr><td>B</td><td>2</td></tr>
<tr><td>C</td><td rowspan="3">3</td></tr>
<tr><td>D</td></tr>
<tr><td>E</td></tr>
</table>
I was wondering if it is possible to have the table embedded inside the td to have the same height as the td.
<table>
<tr>
<td style="background:red">
<table style="background:blue">
<tr>
<td>Hello</td>
</tr>
</table>
</td>
</tr>
</table>
Here is the jsfiddle... https://jsfiddle.net/ekh6z8w0/
As you can see through the fiddle the embedded table is off by a pixel or two. Is it possible to have the blue inside overlap the slight red border?
Remove the padding from td, should work.
td{
padding:0;
}
You can try like this: Demo
CSS:
table>td, table>td>table {
padding:0;
margin:0;
}
table table {
padding:0;
margin:0;
height:100%;
border:1px solid red;
background-color:blue;
color:#fff;
}
HTML:
<table>
<tr>
<td>
<table>
<tr>
<td>Hello</td>
</tr>
</table>
</td>
</tr>
</table>
Hope this is what you want.
I am using Bootstrap.
I have a table, where some rows needs to be grouped with the rows below them.
That means there should be no border between them.
I am wondering if there is an inherent bootstrap way of doing this, or do I need to
put on each tr style="..no border.."
All I care is for the solution to work on Chrome (and nice to have on FF).
<table>
<tr>
<td>
<label>Stuff</label>
</td>
<td>
<label>sdrfg</label>
</td>
</tr>
<tr class="group">
<td>
<label>Other stuff</label>
</td>
<td>
<label>asdfgh</label>
</td>
</tr>
<tr>
<td>
<label>Other stuff</label>
</td>
<td>
<label>asdfgh</label>
</td>
</tr>
</table>
CSS:
table{
width:100%;
border-collapse:collapse;
}
table td{
border-top:1px solid #000000;
}
table tr.group>td{
border-top:none;
}