Body not aligned with header (I know it was already discussed)
Body not aligned with header (I know it was already discussed)
marianopeck
Posts: 53Questions: 8Answers: 0
Hi guys,
First, I am now to the tool, so I am sorry if this is something noob. Thanks for doing such a great product. I hope to use it in production.
I have an app in which I use Twitter Bootstrap tables. And I have the famous problem in which body columns are not aligned with header columns. I have done EVERYTHING I found in the web. Everything. Still no luck. I am using latest DataTables from git, the bootstrap integration package, and bootstrap. I have a zip with the .css and .html with the problem. But not sure where to upload it since it has a few .css , .js and one html. I have also used the DataTables debugger, and ID is 'iqokep'.
Can I provide something else?
Thank anybody that could help me.
First, I am now to the tool, so I am sorry if this is something noob. Thanks for doing such a great product. I hope to use it in production.
I have an app in which I use Twitter Bootstrap tables. And I have the famous problem in which body columns are not aligned with header columns. I have done EVERYTHING I found in the web. Everything. Still no luck. I am using latest DataTables from git, the bootstrap integration package, and bootstrap. I have a zip with the .css and .html with the problem. But not sure where to upload it since it has a few .css , .js and one html. I have also used the DataTables debugger, and ID is 'iqokep'.
Can I provide something else?
Thank anybody that could help me.
This discussion has been closed.
Replies
Allan
I thought that sending the Debug info was enough...Anyway, you can find a zip here: https://dl.dropboxusercontent.com/u/6980943/notAlignedTables.zip. You uncompress, open notAlignedTable.html and you will see the misalinged table.
Thanks!
Unfortunately not for CSS / layout issues. Its only really use for data / misconfiguration issues.
Thanks very much for the files! I've just taken a look and unforunatenyl I can't immediately see what is causing the issue. I was going to dig a bit deeper, but that fact that it is the rendered HTML that is saved in the file, not the the plain HTML, makes that almost impossible. Are you able to also send me the raw HTML please?
Thanks,
Allan
Allan
First, thanks for the answer and for taking a look. Here it is the row HTML BEFORE applying the plugin: https://dl.dropboxusercontent.com/u/6980943/tableBeforePlugin.html. And here, row HTML AFTER plugin: https://dl.dropboxusercontent.com/u/6980943/tableAfterPlugin.html.
IMPORTANT: I noticed something. My webapp, has many tables, say 30. Some of them are correctly aligned and some are not. I can see that those that are misaligned are those in which either 1) I have as many columns that I need an horizontal scroll ; 2) the cell of a table is split and takes more than 1 single "row".
It looks like if the more contents/columns I have (I mean, the more tight I need to be), the most probably the body and the header will be misaligned.
I can share other tables if you want (either aligned or misaligned). Let me know if you want them or if there is anything else I can test.
Thanks!
but still no luck :(
Thanks!
Allan
:S
IMPORTANT: I was able to reproduce it and have a live example here: http://live.datatables.net/oxazuh/5/edit#source
In there, the mis-aligment is very small, but with all my css and libs it is bigger. But maybe it is a start, since it is still a bit shifted.
Thanks guys
Version with bootstrap is: http://live.datatables.net/oxazuh/12/edit#preview
Before you ask: yes, I tried adding the integration with bootstrap you have, but same problem. As you can see in my previous post, I can also reproduce it without bootstrap (but the misaligment is smaller).
Thanks!
*,
*:before,
*:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
the issue appears to resolve. Can you try to replicate this?
I have just tried that and what happens is that it minimizes a lot the mis-aligment. With that change, I get the "small" mis-aligment as I get without bootstrap, that is, http://live.datatables.net/oxazuh/5/edit#preview
Do you see a little mis-aligment as I do?
Allan
Do you also see the misaligment in the link I provided? Thanks!
---+ Border collapse:
Yes indeed, I do see the misalignment you mention! And I think it is caused by the use of border-collapse: collapse. If I set it to separate and add `cellspacing="0"` to the table, it renders correctly: http://live.datatables.net/oxazuh/67/edit .
--- Border styling:
To recreate the effect of the collapsed border, we can remove the existing border options and add:
[code]
div.dataTables_wrapper table {
border-bottom: 1px solid black;
border-right: 1px solid black;
}
div.dataTables_wrapper table th,
div.dataTables_wrapper table td {
border-top: 1px solid black;
border-left: 1px solid black;
border-bottom: none;
}
div.dataTables_wrapper div.dataTables_scrollHead table {
border-bottom: none;
}
[/code]
Result: http://live.datatables.net/oxazuh/68/edit
---+ Bootstrap:
For bootstrap, we need to add:
[code]
table.dataTable,
table.dataTable td,
table.dataTable th {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
[/code]
Bootstrap 3 sets all elements to be a border-box, which is excellent for easy box model calculations, but it totally destroys the column width calculations done by the browser, the above will reset the box model calculations to be the CSS standard for the table and its cells alone.
Result: http://live.datatables.net/oxazuh/69/edit
---+ Changes
I've committed the content box fix to the DataTables / Bootstrap 3 integration files:
https://github.com/DataTables/Plugins/commit/2bd1817
I've also committed that fix to the DataTables main stylesheet for v1.10 - although not directly relevant to Bootstrap perhaps, it will save some difficulties in future I'm sure:
https://github.com/DataTables/DataTablesSrc/commit/f367739
The 1.10 stylesheet already includes the border-collapse: separate setting, and the workaround to make it look like it is collapsed.
---+ Lessons
I really must get on with writing up a tech note about column alignment in DataTables! It will be in as part of the updated site with the 1.10 release...
Thanks for the help with looking into this one :-)
Regards,
Allan
Yes, I can confirm it is fixed. Weird, when I add all my styles, I see the widther border instead of the normal one... (like when separated but with no workaround). I will see if I can find what it is....
I had another misaligned issue but I opened another thread for that.
Thanks a lot!!!
table.table {
clear: both;
margin-top: 0px !important;
margin-bottom: 0px !important;
max-width: none !important;
border-collapse: separate;
}
div.dataTables_wrapper table {
border-bottom: 1px solid black;
border-right: 1px solid black;
}
div.dataTables_wrapper table td {
border-top: 1px solid black;
border-left: 1px solid black;
border-right: none !important;
border-bottom: none;
}
div.dataTables_wrapper table th {
border-top: 1px solid white;
border-left: 1px solid white;
border-right: none !important;
border-bottom: none;
}
div.dataTables_wrapper table tr:hover td {
border-left: 1px solid white;
border-right: none !important;
border-bottom: none;
}
div.dataTables_wrapper div.dataTables_scrollHead table {
border-bottom: none;
}
table.dataTable,
table.dataTable td,
table.dataTable th {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
Some of these, like the white and blue colors are just for my own, but the rest I think could be quite general.
Cheers
Allan
I am trying to apply the fix of the border-collapse and the workaround so that borders do not look widther and I am failing with the usage of FixedColumns :( I tried...but my css skills are quite crappy...
I put a reproducible problem here: http://live.datatables.net/oxazoj/16/edit
From what I know, I am using latest 1.10 and latests from everything. I do include Bootstrap .css integration, dataTables.css etc.
There are basically a few issues that I cannot solve
1) Between the fixed columns (both, left and right) and the part that is next to the rest of the table (not fixed), there is a double border.
2) There is a one-pixel misaligment (horizontally) between the rows of the none-fixed cells and the rows of the fixed cells.
3) Probably because of 1) (or hopefully because of that), my right fixed column always have an horizontal scroll. No matter what width it has (I have other tables with FixedColumns), it will always have an horizontal scroll.
Do you want me to open another thread or this one is fine?
Thanks a lot in advance. If there is anything else I can do, please let me know.
Just go to the last column, let the mouse there, and scroll down until the very very last row... this the misalgiment appeared?
Thanks!!!
Any idea? :(
Allan
Maybe I will put the DataTables in production (in my system) but not using FixedColumns and then as soon as I have that I put it.
Anyway, have a nice weekend, and thanks for your support. If there is anything I could help, let me know.
Best,
Yes indeed (unfortunately ;-) ). Thanks for the test cases - its a massive help!
Allan
i got the same problems.
Have you found a fix for this problem?
Thanks in advance.
Allan
I've been searching through various threads on column alignment problems, FixedColumn problems and Bootstrap problems, and this one seems to cover all of it. I’m still having trouble with header column alignment so I thought I’d provide some examples.
I’m using Bootstrap 3 and FixedColumns, and I’ve played with varying values with sScrollXInner (including leaving it out) and the columns don’t still don’t line up properly.
Also, three problems seem to crop up related to the FixedColumn:
1) Some initial screen sizes (and re-sizes) produce column 2 too narrow, cutting off space to the left of it. The X scrollbar doesn’t appear and allow for movement.
2) Sometimes (when initial screen size is small) the first column has a scrollbar in it. Would nowrap only on this column fix it? If so, are there options to specify that behavior?
3) Sometimes (when initial screen size is large) an extra empty column (which is probably the right portion of the underlying first column) appears between the first and second columns.
Using DataTables 1.9.4:
http://jsfiddle.net/6xEy3/2/
Using this version, to compensate for header miscalculation (gleaned from a few threads on the topic), I can remove the padding and add a span to the header text. But this creates its own set of problems when header text wraps and the FixedColumn problem persists.
http://jsfiddle.net/HDYK6/2/
And finally, moving up to the 1.10-wip version and adding in the Bootstrap integration files (and CSS for FixedColumn), I get a better result in header alignment in this example (with spans and padding fix taken back out):
http://jsfiddle.net/7FFCp/3/
The 1.10 is fine, but:
1) My project goes into production in February and I’m not sure I want to include a nightly library, do you think you’ll have the 1.10 release out before then?
2) Still having the strange FixedColumn problem.
Help is greatly appreciated.