• Resolved jx2900

    (@jx2900)


    Hi,

    I used #colspan# as the top row.
    I have 3 columns in the top row.
    After the second row, I have 9 columns.
    The 2nd and the 3rd columns of the top row have 3 columns each from the second row.

    When I tried to adjust 9 columns_widths, I specified “10%|15%|15%|15%|15%|15%|15%”.
    This didn’t work. But when I specified “10%|45%|45%”, it worked. The first column has 10% and the 2nd and the 3rd columns have 45% each. So 2rd to 9th columns from the second row has even 15% each. I figured out that from the short code the number of column, when used #colspan#, is counted by the top row.

    But then I tried to do text-align and used .tablepress-id-111 { text-aligh:center;} and this didn’t work.
    But when I do the below it worked but columns are recognized not by the top row.
    Columns are recognized as from the second row.

    .tablepress-id-111 .column-1,
    .tablepress-id-111 .column-2,
    .tablepress-id-111 .column-3
    {
    text-align: center;
    color:red;
    }`

    Please visit this page. Password is 321 and hit ENTER. You can see
    https://ichiri.biz/tech/test-page/

    I am using the below short code. As you see, there is only three column widths.
    But the widths of all 9 columns are being arranged.
    [table id=111 column_widths=”10%|45%|45%” /]

    But with the CSS, there are only 3 columns out of 9 columns are decorated.
    I believe that you may already know about this. Due to backward compatibility, I believe that you may not be able to fix this but I hope that knowing this issue, you may be able to keep continuous good quality in the future.

    And I would like to know if #colspan# when #colspan# at the top row is used.there any way I can adjust column_width independently from the second row.

    Best regards,
    Junji

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter jx2900

    (@jx2900)

    Is there any my mistake the below doesn’t?

    .tablepress-id-111
    {
    text-align: center;
    }

    If possible, I don’t have to do like this?

    .tablepress-id-111 .column-1,
    .tablepress-id-111 .column-2,
    .tablepress-id-111 .column-3,
    .tablepress-id-111 .column-4,
    .tablepress-id-111 .column-5,
    .tablepress-id-111 .column-6,
    .tablepress-id-111 .column-7,
    .tablepress-id-111 .column-8,
    .tablepress-id-111 .column-9
    {
    text-align: center;
    }

    Thread Starter jx2900

    (@jx2900)

    Sorry, my mistake, it was 7 rows. So it is:

    .tablepress-id-111 .column-1,
    .tablepress-id-111 .column-2,
    .tablepress-id-111 .column-3,
    .tablepress-id-111 .column-4,
    .tablepress-id-111 .column-5,
    .tablepress-id-111 .column-6,
    .tablepress-id-111 .column-7
    {
    text-align: center;
    }
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Using #colspan# does indeed play a role here, and it’s part of the reason why I don’t recommend using the column_widths Shortcode parameter (secretly, I actually wish that I had never added it…). Due to how it works internally (it only adds the column widths to the first row, which will not be complete if #colspan# is used) it has a lot of issues.
    Instead, I strongly recommend to use the CSS approach from https://tablepress.org/faq/column-widths/

    Regarding the centering: You do not need to specify this for each column separately. Instead, please try

    .tablepress-id-111 th,
    .tablepress-id-111 td {
      text-align: center;
    }

    which should add it to all cells.

    Regards,
    Tobias

    Thread Starter jx2900

    (@jx2900)

    Thank you very much, Tobias,
    This works and this is great.

    .tablepress-id-111 th,
    .tablepress-id-111 td {
    text-align: center;
    }

    And I visited https://tablepress.org/faq/column-widths/ and it is same as the short code.
    Pease revisit https://ichiri.biz/tech/test-page/ with password 321.
    I posted the result.
    I put two tables from the same tablepress-id-111. So I used id(#) instead of class(.).
    *I wanted to use % instead of px.

    /*This is used for both tables. As a text, I used 40% to be distinct.*/
    .tablepress-id-111 .column-1{
    width: 40%;
    }

    /*First row with #colspan# uses the width. So I am not able to control the width of each column.*/
    #tablepress-111 .column-2, <–The first row takes this
    #tablepress-111 .column-3, <–The first row takes this
    #tablepress-111 .column-4, <—The below from here are used from the second row
    #tablepress-111 .column-5, <—but the first row take over controlling the widths.
    #tablepress-111 .column-6,
    #tablepress-111 .column-7
    {
    width: 10%;
    }

    /* I used .row-2. But it seems that .row-2 is ignored for width. The width is controlled by only the first row.*/

    .tablepress-id-111 .column-1{
    width: 40%;
    }
    #tablepress-111-no-2 .row-2 .column-2,
    #tablepress-111-no-2 .row-2 .column-3
    {
    width: 20%;
    }
    #tablepress-111-no-2 .row-2 .column-4,
    #tablepress-111-no-2 .row-2 .column-5,
    #tablepress-111-no-2 .row-2 .column-6,
    #tablepress-111-no-2 .row-2 .column-7
    {
    width: 5%;
    }

    Is there any other way to control width of each row when using #colspan# at the first row?

    Thank you again,
    Junji

    • This reply was modified 3 years, 8 months ago by jx2900.
    • This reply was modified 3 years, 8 months ago by jx2900.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    unfortunately, I can’t check all this, as your site is only giving me an XServer security error 🙁 Maybe some firewall is blocking me?

    But let’s take a step back here and not over-complicate things with that CSS. You will not need (and actually can not) set width for different rows.
    Please describe what you want the columns to do.

    Regards,
    Tobias

    Thread Starter jx2900

    (@jx2900)

    Hi,
    Now you should be able to see the page without password.
    https://ichiri.biz/tech/test-page/

    I just want to know how I can specify different exact widths % for column 6 and 7.

    Best regards,
    Junji

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    you are specifying these widths correctly, but the 5% is just too small. The words in these columns simply require more width, which is why the column is wider than 5%.

    So instead of speculating about the CSS, let’s take a step back: How do you want your table to look like? For me, it actually looks quite nice, with the widths distributed nicely.

    Regards,
    Tobias

    Thread Starter jx2900

    (@jx2900)

    Hi,

    The table is just for a test.

    I would like to specify each column width individually without evenly split based on the column width of row 1 with #colspan#.

    Is there any way to do that? If not, it’s okay. It is not too critical.

    Best regards,
    Junji

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    the best approach should be to assign the width individually, pretty much like you do above.
    Rows with #colspan# can indeed make things tricky. I recommend to investigate this with the browser developer tools. You will then e.g. see that for your first row (ピン番号 / SD / microSD), the applied CSS classes of the three cells are actually .column-1, .column-2, and .column-5. So, in the end, there will be cells with .column-2 that have different widths when rendered (even though the CSS sets them to the same value), and the same for .column-5.
    It will be a bit of trial and error, essentially.

    Regards,
    Tobias

    Thread Starter jx2900

    (@jx2900)

    HI Tobias,

    I actually used CTLR+SHIFT+I (Chrome DevTool) to check applied CSS with those .column-N and HTMT class and id before sending you message 2 days ago. And as the result, the first row took the control and the second row or below doesn’t take “width” property with .column-N.

    I think that it is not possible yet at this moment and I will use TablePress within what it can do. It is still way better plug-in for table than any others. So I will stop bothering you. But thank you very much for spending time for me.

    I have given 5 stars to TablePress.

    Best regards,
    Junji

    • This reply was modified 3 years, 8 months ago by jx2900.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    correct, the Shortcode parameter will only add the width CSS to the first column. That’s why I recommend the CSS approach.

    Good to hear that you like TablePress so much 🙂

    Regards,
    Tobias

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Discrepancies in counting columns between short code and css’ is closed to new replies.