table columns does not show up in resize - html

I have three tables......
The first table is not given margin left.....
where as the next two tables i have given margin-left to move it slightly on the left side....
but when i resize the window i am not able to see the last column in other two tables....
how to fix it....
the first table looks fine even even after resize......
http://jsfiddle.net/x7HD9/
providing my code below
<table class="table" style="margin-left: 160px; width: 1759px;">
<thead>
<tr class="subBomListHeading subBomHeading" style="">
<th>BOM Type</th>
<th>Product P/N</th>
<th>Version</th>
<th>Brand Name</th>
<th>BOM Description</th>
<th>Generation</th>
<th>Version</th>
<th>Notes</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr style="background-color: #e5dcd1;" class=" subBom">
<td>sub BOM</td>
<td>99-00302-00</td>
<td>v.02</td>
<td>Creative</td>
<td>Hardware v1.0 System</td>
<td>G1</td>
<td>1</td>
<td>new</td>
<td><input type="radio" name="sex" value="male"></td>
</tr>
</tbody>
</table>

Try :
<table class="table" style="margin-left: 160px; width: 100%;">
Also, keep in mind that <tables> are not 'responsives' (has in 're-layout'), but still 'extensibles'.
Your table is displayed at it's minimum width, it's normal you don't see the last column, it overflows the viewport.

Im going to assume you have width: 100% set on your tables, thats your problem, they are set as the width of the window and then moved right so you cant see the last column, You should change the width to a lower value.

You have a couple problems here.
First, you've defined a fixed width to the tables. Depending on how the overflow property is set on ancestor elements, it can cause the clipping you describe because the element is too wide for that space. It's unclear as to how wide you want these elements to be, but something like this would do the trick:
table.brown {
min-width: 80%; /* or just plain `width: 80%` */
}
Ultimately, there will come a point where you won't be able to resize because the contents of the table simply won't allow it. Once your cells are down to 1 word wide, there's not much you can do to help longer words like "Description" without adding word-break: break-all.
Second, you want to use a different setting for your margins if you want to push it in a particular direction. Using auto as the value for margin-left would cause the element to shift all the way to the right.
table.brown {
margin-left: auto;
}
http://jsfiddle.net/x7HD9/3/

There's way too much CSS for me to even try and comprehend. I think starting from scratch with just a table and then gradually add CSS would be a good idea.

Related

Is there a case when table cell will ignore min-width?

I have a table with table-layout set to fixed. In the first row I have a td with text inside. It's something like:
<table>
<tbody>
<tr>
<td colspan="2" style=" min-width: 250px; width: 100%;">
<b>Vendor/Firm Information</b>
</td>
</tr>
<tr>
some content
</tr>
... and so on
</tbody>
</table>
So, the width of the first row is actually less than 250px. It's even less than content. So, I need to know: is there any reason for that? Is there something that don't allow the table cell to take appropriate width?
I use old version of Chrome (22.0.1229.0) and I think that it's rather a bug than incorrect styles.
In latest Chrome everything is alright.
I think that colspan="2" there is the reason.
There is no reasonable way to split that min-width between two spanned columns. So min-width constraint just get ignored on spanned cells.
Please see the response here:
Chrome, Safari ignoring max-width in table
The gist is that "max-width" only applies to block elements. So setting the table to "display: block;" should resolve the issue.

How do I make row separator/bottom-border that isn't 100% width?

I've got a set of tabular data that I'm presenting in a standard HTML table tag. The design calls for a one pixel separating line between each row as well as having all cells in a given row be vertically centered against each other. The various rows and cells can have an arbitrary height and need to grow based on the content inside of them.
The tricky piece here comes from the fact that the one pixel separating line is supposed to stop 15px from either side of the edge of the table. My initial inclination to solve this is to merely add a border-bottom to either my <tr> or <td> tags, however, I couldn't for the life of me figure out any sort of way to not get the line to go all the way across. If I put <div> tags inside of the <td> tags, I can then apply the border to there, but then my border bottom is right up against the bottom of the content rather than at the bottom of the row.
The only thing I've been able to make work feels really "dirty" to me.
<table>
<tr>
<td style="width: 15px;"> </td>
<td style="border-bottom: 1px solid gray;">My table data</td>
.... more cells here as needed
<td style="width: 15px;"> </td>
</tr>
</table>
This works because I add those two spacer cells on either end of the row. I've even gone pretty far down some non-table solutions, but I always run into issues trying to get the content to grow correctly (i.e. no absolute positioning in the various rows) and/or getting things to vertically center and wrap like they are supposed to.
Anybody have any better ideas? If it helps, I'm only supporting "newer" browsers, e.g. IE9+/etc, including mobile.
You can try adding a new row between each pair or rows with colspan="n" where n is the total number of collumns, and inside that new row you put a div with the desired specs (I would say 1px height, for instance).
HTML, add this between your rows:
<tr class="test_tr" >
<td colspan="3"><div class="test_div"></div></td>
</tr>
CSS:
.test_tr
{
height: 1px;
}
.test_div {
height: 1px;
width: 80%;
background-color: red;
margin: 0 auto;
}
Here is the Fiddle: http://jsfiddle.net/Y8eWR/

CSS table 100% width, td width

Edit 2:
Problem seemed to reside on "bigTable" elements th rules. Apparently th's were inheriting wrong min-width's when used on layout-template. I'm still investigating this.
Still, I'm going to give one more try for divs. One big problem was using fixed nav and dynamic content, but I already found Holy Grail -solution for this (http://alistapart.com/article/holygrail).
Thanks for suggestions & all the lovely trolololo.
Edit:
I replicated this problem to http://jsbin.com/eyitij/4/edit
I have a strange problem with table + td width. I have code similar to this:
<table class="mainLayout" style="width: 100%;">
<tr>
<td style="width: 250px;">
<div id="leftNavigationPanel"> * content * </div>
</td>
<td id="panelCell">
<div class="panel">
<table id="bigTable" width="100%"> * LOTS OF CONTENT, includes big table * </table>
</div>
</td>
<tr>
</table>
When I run this code on browsers, mainLayout is getting overflowed, so it becomes 3600px, and this happens because of big table inside Panel.
Big table I'm referring to can be contained within screen. When done so, it gets horizontal scrollbar (which is what I want). This works if big-table is loaded in separate html-file with rule "width: 100%".
After adding mainLayout a rule "display: block;", mainLayout table is rendered ~1800px and is contained within screen, but problem is that "panelCell"-TD is still ~3400px wide, so I'm still having whole page scrolling... TD isn't contained within table, but always expands to 250px + bigTable.width() !?
Basically browser doesn't know how to calculate "panelCell" to fill only : window.width - leftNavigationPanel.
Any ideas how to make right rules without using javascript + precalculated max-width rule for "panelCell"?
panelCell must be contained within window
bigTable must be contained within panelCell, with scrollbar
Setting table-layout:fixed fixes a lot of weird problems with tables :
<table style="table-layout:fixed;">
<col style="width:250px"/>
<col/>
<tr>
...

Tables automatically have same width

Ok, my problem is this, I had one master table and the <td>'s withing the table all aligned up pefectly and expanded nicley if header <th>'s wre beigger etc...
I had to break this table into 2 tables because I want the top portion to sort independent of the bottom section. Problem now is I have to manually set the width of the <td>'s in the bottom table so it has the same width as the top table. Is there a way for them to set automatically?
<table align="center" class="data_table" style="border-bottom-style: none; margin-bottom: 0px;">
<tr>
<th>
</th>
</tr>
</table>
<table align="center" class="data_table" style="border-top-style: none; margin-top: 0px;">
<tr>
<th colspan="9 title="Source of Repair (SOR) Remarks">SOR Remarks</th>
</tr>
<tr>
<td width="845px" colspan="9">
<textarea name="mcRemark" rows="7" cols="100" scrolling="auto">${mcRemark}</textarea>
</td>
</tr>
This
<td width="845px" colspan="9">
is the size of the top table and could change....thats my problem
They are now independent tables so the widths will be different.
You could use the data_table class to set the width of the cells in both tables to be the same.
Otherwise I'd imagine you could use javascript to grab th width of teh first table's cells and use those values to set the second table's cells. Bit messy though.
Without going with a javascript/jQuery solution, no, there is no way to do this with simple HTML/CSS. Rethink your solution by containing all data in one table, that way the TH's will dictate the column widths.
You could put them back in the same table and then pick a row to divide them and style that row to make it invisible. Through border colors and background colors. Faux two tables.

How do I specify that a html cell should have the minimum width it needs to display all of its content

In the following example,
<table style="width: 100%;"><tr>
<td>First Cell</td>
<td>Second Cell</td>
</tr></table>
How do I set the widths so that the first cell/column is exactly as wide as it needs to be to show the content of the first cell and let the second cell fill the rest of the width of the table?
I'm using a GWT HorizontalPanel to do this, so if there's either a html, css or gwt trick. Please let me know.
Thank you
Assuming that “as wide as it needs to be to show the content of the first cell” refers to width needs to show the content without line breaks, you can use something like this:
<table width=681 border><tr>
<td nowrap>First Cell</td>
<td width="100%">Second Cell</td>
</tr></table>
There is no guarantee that this will keep working, since requiring a cell to be 100% wide, yet include another cell with nonzero width, is an impossible requirement. But browsers currently do what seems to be closest to the requirement.
You could achieve the layout you’re aiming for without tables, as explained in this question:
xHTML/CSS: How to make inner div get 100% width minus another div width
HTML
<div class="two-columns">
<div class="fit-to-contents">First Cell</div>
<div class="fill-remaining-space">Second Cell</div>
</div>
CSS
.two-columns {
overflow: hidden;/* Contains descendant floats */
}
.two-columns .fit-to-contents {
float: left;
background: #ffd;
}
.two-columns .fill-remaining-space {
overflow: hidden;
background: #fdf;
}
I’m not sure if that would actually be appropriate for your use-case though, I’d need to see the context.
Tables take care of themselves in HTML. There is no need to force any cell to be any particular size.
What is it you're really trying to do?
What version of HTML are you using? (Hint: Upgrade to HTML5 and CSS!)
Just don't specify any widths at all (neither on the table nor on the cells) and use white-space: nowrap on your table cells.
Put a style of width:1px on the first cell. The table will then make the first cell as narrow as possible, without causing overflow.
Since "as narrow as possible" is the width of the word "First" in this case, you may want to throw in a white-space:nowrap too, otherwise it will display "First" and "Cell" on two lines.
Jsfiddle