Column Width Weird In Spite Of CSS
-
Hi, Tobias,
I am trying to build a table and put this code in settings / CSS-Code. But whatever I do the width doesn´t change. What can I do?
/* Breite von Spalte 1 */
#tablepress-id-3 .column-1 {
width: 400px;
}/* Breite von Spalte 2 */
#tablepress-id-3 .column-2 {
width: 20px;
}/* Breite von Spalte 3 */
#tablepress-id-3 .column-3 {
width: 20px;
}
-
Hi,
thanks for your question, and sorry for the trouble.
The reason for this is that you are using ID-based CSS selectors but with the names of the class-based selectors. Please try again with
/* Breite von Spalte 1 */ .tablepress-id-3 .column-1 { width: 400px; } /* Breite von Spalte 2 */ .tablepress-id-3 .column-2 { width: 20px; } /* Breite von Spalte 3 */ .tablepress-id-3 .column-3 { width: 20px; }
(If you want to continue using the ID-based selector, that would be
#tablepress-3
instead of#tablepress-id-3
here.)Regards,
TobiasHi, Tobias,
thanks for answering so soon.
I tried both (#tablepress-3 and .tablepress-id-3) and none of it works.
I use another css-code which doesn´t work either:
/* Zentrieren von Text */
.tablepress-id-3 .column-2,
.tablepress-id-3 .column-3,
.tablepress-id-3 .column-8 {
text-align: center;
}Hi, Tobias,
it seems to me that the smallest possible width of a column is defined by the widest text in on of the cells. What do you think of that?
Cheers
Hi, Tobias,
and another issue I noticed: The preview inside TABLEPRESS looks completely different than the preview inside DIVI.
I´m going to talk about this with the DIVI support.
Thanks for your help.
Cheers
Hi,
correct, the smallest width is determined by the widest text in the cells of a column (because the browser will not add word-wrapping automatically).
And yes, the preview is looking differently in many cases (as explained in the short introduction text above the table there), because the preview does not use the theme CSS, which can also contain commands that affect tables.
Can you maybe post a link to the page with the table where this problem happens, so that I can take a direct look? Maybe I can make some suggestons.
Regards,
TobiasHi, Tobias,
originally it was not the plan to publish the page. Well, ok, here it is: http://www.staendigerkaeltet.de/test/
I contacted the DIVI support. We´ll see.
Hi,
thanks for the link! One idea here would be to reduce the padding (inner white space) in the cells, which is set rather big by the theme. For that, please add this to the “Custom CSS” textarea on the “Plugin Options” screen of TablePress:
.entry-content .tablepress-id-3 thead th, .entry-content .tablepress-id-3 tbody td { padding: 8px; }
Regards,
TobiasNo, sorry, Tobias.
Seems to be little better but I´m not sure just from watching. That´s nothing like enough.
Hi,
the CSS worked, so that’s good. As you can see, the words in the header row are now much closer together. To make more columns fit, you will now either have to reduce the font size in the table, e.g. with
.tablepress-id-3 th, .tablepress-id-3 td { font-size: 12px; }
or add manual hyphenation or line breaks to the long words like “Salzinhalator” or “Raumluftreiniger”,
or increase the overall width of the table, for which you will have to increase the content area in the theme (which currently is 960px wide). For that, you could check if the theme maybe offers a “Full page” page template on the “Edit” screen of the page.Additionally, I suggest to switch to a different type of horizontal scrolling. For that, please uncheck the “Use DataTables” checkbox on the table’s “Edit” screen and instead apply the approach from https://wordpress.org/support/topic/responsive-tables-scroll-only?replies=6#post-5511954
Regards,
TobiasHi, Tobias,
yes, you´re right. I will decide which of the options are ok for us. And yes, the theme offers a “Full Page”, but the table is part of a landing page which doesn´t use “Full Page” format.
I tried your suggestion regarding scrolling. And, yes, it seem that this could be the solution.
In the meantime a DIVI supporter made this additional suggestion:
.tablepress-id-3 .column-1 {
width: 146px !important;
}
.tablepress td {
font-size: 14px;
margin: 0 !important;
max-width: 65px !important;
padding: 0 !important;
}
.tablepress thead th {
font-size: 11px;
margin: 0 !important;
max-width: 98px;
padding: 0 !important;
}I played with some values, shortened some phrases and it looks almost ok. Except the table head. I deleted every single soft return within the head cells and replaced it by blanks. However, it seems as if returns would be there.
Last issue would be: Do you have a suggestion for the first cell “Produkt / Nutzen”? You see that “Produkt” means the table head and “Nutzen” means the first columns. Can this be displayed more appropriate?
Hi,
ok, they are basically also suggesting to reduce the font size and padding the cells.
For the problem with the header row, I suggest to change.tablepress thead th { font-size: 11px; margin: 0 !important; max-width: 98px; padding: 0 !important; }
to
.tablepress thead th { font-size: 11px; max-width: 98px; padding: 5px 0 !important; }
I see what you mean with “Produkt / Nutzen”, but I don’t have an idea here, except maybe that you use an image instead, that has a 45º line in it or something. Just with text, we can’t really achieve that.
Regards,
TobiasHi, Tobias,
an image “Produkt / Nutzen” could be the right solution. I´ll try this.
Regarding the rest: I like it very much to see that a solution can be founde by working together. Your last suggestion to omitte ” margin: 0 !important;” and add “padding: 5px 0 !important;” doesn´t bring a change.
Hi,
ah, I actually forgot to add a line that I wanted to add, sorry… The other two changes are just some cleanup. Please try again with
.tablepress thead th { font-size: 11px; max-width: 98px; padding: 5px 0 !important; line-height: normal; }
Regards,
TobiasWell, that looks fine. I added “vertical-align: text-top;” and now everything is ok.
Thanks a lot for your phantastic support. It´s not so oftten that I experience commitment like yours. Thanks and all the best for you and your project.
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Best wishes,
TobiasP.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!
- The topic ‘Column Width Weird In Spite Of CSS’ is closed to new replies.