[table] formatting

Started by MrMeeses, October 07, 2022, 02:39:49 PM

Previous topic - Next topic

MrMeeses

[table][tr][td]
I can't center this formatting on any posts.

For example:



line 1

line 2

Line 3
Line 4
                             
line 1

line 2

Line 3
Line 4



I want the above table in the center. It used to work fine on SMF 2.0x but not 2.1.

Any support would be appreciated.

Cheers.

Antechinus

Seems to work as it should here:
[table]
[tr]
[td]Cell 1[/td][td]Cell 2[/td][td]Cell 3[/td]
[/tr]
[tr]
[td]Cell 1[/td][td]Cell 2[/td][td]Cell 3[/td]
[/tr]
[tr]
[td]Cell 1[/td][td]Cell 2[/td][td]Cell 3[/td]
[/tr]
[/table]
Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3

MrMeeses

Quote from: Antechinus on October 07, 2022, 09:22:01 PMSeems to work as it should here:
[table]
[tr]
[td]Cell 1[/td][td]Cell 2[/td][td]Cell 3[/td]
[/tr]
[tr]
[td]Cell 1[/td][td]Cell 2[/td][td]Cell 3[/td]
[/tr]
[tr]
[td]Cell 1[/td][td]Cell 2[/td][td]Cell 3[/td]
[/tr]
[/table]




Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3

Doesn't answer my question. I want the table centered in the page using
[center][/center]
Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3

Trying to do that above does not work. It worked fine in SMF 2.0x.

Aleksi "Lex" Kilpinen

#3
Yup, it seems you can't center a table - Below is all between one center BBC, first outside a table, then inside a table.

8)



8)


Not sure about this, but sounds like this could be seen as a bug, even though [center] isn't really recommended at all anymore.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Shades.

Quote from: MrMeeses on October 08, 2022, 02:11:00 AMDoesn't answer my question. I want the table centered in the page using
For a work around you can install this mod and then use the following html code:

[html]<center><table>
<tr>
<td>Cell 1</td></tr>
<tr>
<td>Cell 2</td></tr>
<tr>
<td>Cell 3</td></tr>
</table></center>[/html]

You cannot view this attachment.
ShadesWeb.com - Custom Logos - My Themes on SMF | My Themes on ShadesWeb
https://shadesweb.com

BikerHound.com - Sniffing out the road ahead
https://bikerhound.com

Dream as if you'll live forever; Live as if you'll die today. - James Dean

Illori

Quote from: Shades. on October 08, 2022, 05:21:35 AMFor a work around you can install this mod and then use the following html code:


you dont need that mod to be able to use html bbc. but you do need to be the admin

Steve

Quote from: Aleksi "Lex" Kilpinen on October 08, 2022, 03:01:47 AM[center] isn't really recommended at all anymore
Why is that? What are we supposed to use instead?
My pet rock is not feeling well. I think it's stoned.

Kindred

Center html is deprecated, iirc

We're supposed to be using css positions like text-align

Which makes it hard for forums and other user generated content...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

MrMeeses

I'm speaking of bbCode and centring tables using it in 2.1 if that's possible. If not, I would consider it a bug in SMF 2.1 software. Hopefully its fixed ASAP.

Steve

Quote from: Kindred on October 08, 2022, 08:23:36 AMCenter html is deprecated, iirc
That I knew but Lex said [center] which I thought meant bbcode.
My pet rock is not feeling well. I think it's stoned.

Aleksi "Lex" Kilpinen

Quote from: Steve on October 08, 2022, 11:41:38 AM
Quote from: Kindred on October 08, 2022, 08:23:36 AMCenter html is deprecated, iirc
That I knew but Lex said [center] which I thought meant bbcode.
That's the thing, they are one and the same.
EDIT: Actually... Looking at the source, I'm not sure if that's the case anymore. At least it used to be.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Antechinus

FFS. Look, if you want to centre an inline or inline-block element, you can use text-align: center; on the parent.
If you want to centre a block level element, like a div or a table, it needs to have a restricted width that is less than the parent element, and it needs to have left and right margins set to auto.

This is dead basic. Everyone here should already know it. Why are people running in circles about it? :P


Quote from: MrMeeses on October 08, 2022, 02:11:00 AMDoesn't answer my question.
Then I suggest you make your OP clearer, since the only code you said was not working was this:

Quote from: MrMeeses on October 07, 2022, 02:39:49 PM[table][tr][td]

If you want to centre a table that has a restricted width less than ts parent container you would need two options in BBC:

1/ The ability to set a width on the table itself.
2/ The ability to set left and right margins on the table.

The easiest way of doing this in practice, so that it can handle all block level elements, would be to create a BBC tag that does this:
<div style="max-width: $1; margin: 0 auto;">

</div>
And you just drop your table or whatever inside that tag. That means you don't need to be able to set a width on the content, since it will fill the wrapper div provided by the tag.

For inline elements (spans, links, etc.) the existing BBC centre tag should work (I assume it already it uses text-align: center;).

If you want one tag that can handle both block level and inline elements, you could set up your tag like this:
<div style="max-width: $1; margin: 0 auto; text-align: center;">

</div>
Caveat: that will also centre all content inside each child element, so if you want left-aligned table cell content inside a centred table you would have use a left justification tag inside the centre tag.

But whatever. It's not hard to do. :)

Kindred

Quote from: Antechinus link=msg=4136431 date=1665254944-But whatever. It's not hard to do. :)

Except it is difficult to do as a bbcode...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Antechinus

Ok. I've written far more complex BBCodes than this one. It seems pretty straightforward to me. What, exactly, is the difficult bit?

live627

Quote from: MrMeeses on October 08, 2022, 02:11:00 AM. I want the table centered in the page using
[...]
Trying to do that above does not work. It worked fine in SMF 2.0x.
find in index.css.bbc_table {
font: inherit;
color: inherit;
}
and replace it with.bbc_table {
margin: auto;
font: inherit;
color: inherit;
}

Kindred

Live, that will make ALL BBC tables centered
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

MrMeeses

Quote from: Antechinus on October 08, 2022, 02:49:04 PM
Quote from: MrMeeses on October 08, 2022, 02:11:00 AMDoesn't answer my question.
Then I suggest you make your OP clearer, since the only code you said was not working was this:

Quote from: MrMeeses on October 07, 2022, 02:39:49 PM[table][tr][td]


If you read what I said, I rather clearly pointed out:

Quote from: MrMeeses on October 07, 2022, 02:39:49 PMI can't center this formatting on any posts.

For example:



line 1

line 2

Line 3
Line 4
                           
line 1

line 2

Line 3
Line 4



I want the above table in the centre. It used to work fine on SMF 2.0x but not 2.1.

I want to be able to CENTRE the table. It worked fine in SMF 2.0x, but does not in 2.1.

Quote from: live627 on October 10, 2022, 04:42:27 AM
Quote from: MrMeeses on October 08, 2022, 02:11:00 AM. I want the table centered in the page using
[...]
Trying to do that above does not work. It worked fine in SMF 2.0x.
find in index.css.bbc_table {
font: inherit;
color: inherit;
}
and replace it with.bbc_table {
margin: auto;
font: inherit;
color: inherit;
}


I appreciate the response, though I do have a concern as Kindred pointed out, I wouldn't like to make all BBC tables centred.

To sum up, is there a way to allow for tables to be aligned left, centre or right like in SMF 2.0 where you simply used the respective bbCode? They still works for most things but not for tables.

Antechinus

#17
Ok, quick test:

[table][tr][td]Cell 1[/td]
[td]Cell 2[/td]
[td]Cell 3[/td]
[/tr]
[tr][td]Cell 1[/td]
[td]Cell 2[/td]
[td]Cell 3[/td]
[/tr]
[tr][td]Cell 1[/td]
[td]Cell 2[/td]
[td]Cell 3[/td]
[/tr]
[/table]

[float=left max=45%]
[table][tr][td]Cell 1[/td]
[td]Cell 2[/td]
[td]Cell 3[/td]
[/tr]
[tr][td]Cell 1[/td]
[td]Cell 2[/td]
[td]Cell 3[/td]
[/tr]
[tr][td]Cell 1[/td]
[td]Cell 2[/td]
[td]Cell 3[/td]
[/tr]
[/table]
[/float]

[float=right max=45%]
[table][tr][td]Cell 1[/td]
[td]Cell 2[/td]
[td]Cell 3[/td]
[/tr]
[tr][td]Cell 1[/td]
[td]Cell 2[/td]
[td]Cell 3[/td]
[/tr]
[tr][td]Cell 1[/td]
[td]Cell 2[/td]
[td]Cell 3[/td]
[/tr]
[/table]
[/float]

Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3

Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3

Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3
Cell 1Cell 2Cell 3

This works, if I also edit the bbc_table class to include margin: 0 auto; (as per live627's suggestion*). IOW, set tables centred by default, then use a left or right float tag if you do not want the table centred.

The problem then becomes separating other content after the float tags, if you want a clean break there. The default hr tag seems to deal with that, if clear: both; is added to the CSS for hr's.

hr {
border: none;
margin: 12px 0;
height: 2px;
background: #fff;
box-shadow: 0 1px 0 #bbb inset;
clear: both;
}

*I tested this here in my document inspector. So, it's not visible in this post, but can easily be added by anyone else who wants to test it in their document inspector.

Sesquipedalian

.centertext .bbc_table {
    margin: auto;
}
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

MrMeeses

Tried a couple of things recommended here but unfortunately to no avail.

Does anyone know if there's any planned fix for this or a package that fixes the issue? That would be most convenient and would help fix the problem.

Cheers!

Advertisement: