• Resolved thouston

    (@thouston)


    Hi Tobias. I have several tables to which I want to apply a special width. So in my plugin options I have
    .wp-table-reloaded-id-5 {
    width: 400px;
    }

    If I want more tables (but not all) to have this width, do I have to repeat the whole code snippet for each table or is there a quicker/neater way of doing it e.g.
    .wp-table-reloaded-id-5 id-7 id-15 {
    width: 400px;
    }

    If so what’s the correct syntax?

    Many thanks as ever for a fab plugin

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your question!

    The correct syntax would be

    .wp-table-reloaded-id-5,
    .wp-table-reloaded-id-7,
    .wp-table-reloaded-id-15 {
      width: 400px;
    }

    (The entire selector part has to be repeated, separated by commas.)

    However, there might be a better way for you, by using the “Custom CSS class” feature.

    You could, for example, invent a new CSS class name “wp-table-reloaded-width-400”, which gets the following “Custom CSS”:

    .wp-table-reloaded-width-400 {
      width: 400px;
    }

    Now, to apply this to a table, just add the string “wp-table-reloaded-width-400” (without the “”) into the “Custom CSS class” textfield on the “Edit” screen of each table that shall get this width (in your case, tables 5, 7, and 15).

    In summary, this approach works by creating more generic CSS classes, which apply certain styling properties to a table (in your case the width, but that can be extended to anything you want). To apply that CSS class (and with that all of that class’s styling) to a table, it just needs to be added to the mentioned “Custom CSS class” textfield on the table’s “Edit” screen. The CSS code for the class goes into the “Custom CSS” textarea on the “Plugin Options” screen, as usual.

    Best wishes,
    Tobias

    Thread Starter thouston

    (@thouston)

    Thank you Tobias – that second suggestion is a much better way of doing it as this will be much easier for my administrator to do without having to amend code in the options.

    Really appreciate the prompt response ??

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome!

    Best wishes,
    Tobias

    Thread Starter thouston

    (@thouston)

    The trouble with showing me a lovely feature like this – which is working beautifully – is that I get greedy and want to do lots of things like this. So forgive the next question but..

    Can I have more than one custom CSS class on the table? I tried ; , and space and non worked.

    Secondly, I have this code at the moment

    .wp-table-reloaded, .wp-table-reloaded td, .wp-table-reloaded th {
    border: none!important;
    border-collapse: collapse!important;
    border-spacing: 0px!important;
    }

    Again if I could make this a custom class I could apply it to specific tables rather than all at the moment. Is that possible given the addition of td and th in there?

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    nice to hear that you like this feature so much ??

    Yes, of course you can have several “Custom CSS classes”. In the textfield, they simply need to be separated by a space, for example

    wp-table-reloaded-width-400 wp-table-reloaded-second-custom-class

    (As you say that the space did not work for you, can you provide a link to the page with the table where this does not work?)

    And yes, you can use “Custom CSS classes” for code fragments which use td and th, as well. You would simply replace all existing occurances of .wp-table-reloaded with .wp-table-reloaded-your-custom-class.

    Regards,
    Tobias

    Thread Starter thouston

    (@thouston)

    I sorted the two classes question. My custom class was
    .wp-table-reloaded-inarticlesquicklinks-column1 {
    width: 250px
    }
    and of course should have been
    .wp-table-reloaded-inarticlesquicklinks-column1 .column-1 {
    width: 250px
    }

    So that works now.

    I’ll be honest – I’m not sure what the td and th do – I’d just copied that code from guide on your website! So how would I make that into a class – just not sure on the exact syntax.

    .wp-table-reloaded, .wp-table-reloaded td, .wp-table-reloaded th {
    border: none!important;
    border-collapse: collapse!important;
    border-spacing: 0px!important;
    }

    Would it be something like
    .wp-table-reloaded-noborder td th {
    border: none!important;
    border-collapse: collapse!important;
    border-spacing: 0px!important;
    }
    ..that doesn’t look quite right. My custom class from this would be wp-table-reloaded-noborder

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    nope, that would be

    .wp-table-reloaded-noborder, .wp-table-reloaded-noborder td, .wp-table-reloaded-noborder th {
      border: none!important;
      border-collapse: collapse!important;
      border-spacing: 0px!important;
    }

    The td refers to all table cells in the “body” of the table, while the th refers to all table cells in the “header” of the table. Thus, this code removes the borders from the table (outside of it), all body cells, and all header cells.

    Best wishes,
    Tobias

    Thread Starter thouston

    (@thouston)

    Thank you Tobias – again I really appreciate your support and hopefully that’s all I need for now.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    sure, always glad when I can help ??

    Regards,
    Tobias

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[plugin: wp-table-reloaded] apply options to multiple tables’ is closed to new replies.