News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Tables are not centered in 2.1.4

Started by HelAu007, July 12, 2023, 06:54:51 AM

Previous topic - Next topic

HelAu007

Hello
We just upgraded from 2.0.x to 2.1.4.
Overall its a great improvement, thanks !!!
In the old version, tables could be centered, now these are all shown at the left
Regards
Helmut

Sir Osis of Liver

When in Emor, do as the Snamors.
                              - D. Lister

Aleksi "Lex" Kilpinen

Default:

This is a table.
R1C1000R1C2000R1C3000
R2C1R2C2R2C3
R3C1R3C2R3C3
Here ends said table.

Centered:

This is a table.
R1C1000R1C2000R1C3000
R2C1R2C2R2C3
R3C1R3C2R3C3
Here ends said table.

I assume you were able to actually center the table, as now it seems to only center the contents within the table?
I'm not sure what has changed, but it would make sense to center the whole table if you wrap it in center tags.

Calling this a possible bug, moved to bug reports.
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

HelAu007

Exactly, and the funny thing, on a mobile its right aligned, on a PC left aligned.
[center]This is a centered text above a table
[table][tr][td]A1[/td]
[td]B1[/td]
[/tr]
[tr][td]A2[/td]
[td]B2[/td]
[/tr]
[/table]
[/center]
And I have attached screenshots from the preview on 2.1.4 and an older one

Sir Osis of Liver

Table is centered in 2.0, not in 2.1.  It's a bug.
When in Emor, do as the Snamors.
                              - D. Lister

Diego Andrés

Is it supposed to look like this?
You cannot view this attachment.

Should be easy to fix.

.centertext table {
  margin-inline: auto;
}

SMF Tricks - Free & Premium Responsive Themes for SMF.

Aleksi "Lex" Kilpinen

I think I would actually need to test and see how the table, versus the table contents, acted in different situations on 2.0, but before that at least that seems better than it is now.
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

HelAu007

Quote from: Diego Andrés on July 12, 2023, 01:45:53 PMIs it supposed to look like this?
You cannot view this attachment.

Should be easy to fix.

.centertext table {
  margin-inline: auto;
}
Yes its supposed to look like this.
What exactly can I do to check this ?

Kindred

Сл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."

Sir Osis of Liver

You can't center a table in 2.1 with bbc tags.  This doesn't work either -


[center][table][tr][td]A1[/td]
[td]B1[/td]
[/tr]
[tr][td]A2[/td]
[td]B2[/td]
[/tr]
[/table][/center]


A1B1
A2B2
When in Emor, do as the Snamors.
                              - D. Lister

Antechinus

No, it wouldn't. Tables are a block level element, and text-align only works on inline elements. Use margin: 0 auto; instead. If that does not exist, make a BBC tag for it (should be a no brainer).

Sir Osis of Liver

Well, that's really the point.  It should work with default tags in reply editor, but it doesn't.  You can work around it, so can I, but shouldn't be necessary for members to mess with it.
When in Emor, do as the Snamors.
                              - D. Lister

Antechinus

Yes, but I'm thinking of the easiest fix for it.

In practice you need to do two things: centering inline elements (text-align: center;) because inline elements cannot have a margin set, and centering block level elements (margin : 0 auto;) because text-align doesn't work on them.

The easiest way to do it all with one tag is probably to make the centertext tag create the usual div (with text-align: center;) with another div inside it (set to display: inline-block;) and the content of the tag goes inside the second div. That way it doesn't matter if the content is an inline element or a block level element. A div is a valid wrapper for both, and if set to inline-block it will shrink to the width of the content, and it will accept text-align: center; and behave itself. :)

Chen Zhen


I never looked at BBC tables in 2.1 until this thread but shouldn't it be updated to use div tables?
Also if the tables are given 100% width then it centers.


My SMF Mods & Plug-Ins

WebDev

SMF support staff should be shaping a positive community experience & not provoking an argument or emotional reaction.

Kindred

No tables are actually tables,  not divs
Сл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."

live627

why does it not use the center tag? and why delve deeper into divitus?

Antechinus

Quote from: live627 on July 14, 2023, 02:13:41 AMwhy does it not use the center tag?
I explained that already. The text-align: center; doesn't work on block level elements, and a table is a block level element. However, the fix I suggested will work for tables too. I tested it live. It works. It works if you put a table in the inner (second) div, and it works if you put a third div (ie: display: block;) inside the second div.

In both cases the inner div shrinks to the width of the target element's content, and the whole kaboodle then behaves when it is told to use text-align: center;

Which is the result you want, yes?

Quote from: Antechinus on July 13, 2023, 05:44:29 PMIn practice you need to do two things: centering inline elements (text-align: center;) because inline elements cannot have a margin set, and centering block level elements (margin : 0 auto;) because text-align doesn't work on them.

The easiest way to do it all with one tag is probably to make the centertext tag create the usual div (with text-align: center;) with another div inside it (set to display: inline-block;) and the content of the tag goes inside the second div. That way it doesn't matter if the content is an inline element or a block level element. A div is a valid wrapper for both, and if set to inline-block it will shrink to the width of the content, and it will accept text-align: center; and behave itself. :)

Sir Osis of Liver

When in Emor, do as the Snamors.
                              - D. Lister

Antechinus

Probably because 2.0 used the old (now-deprecated) HTML center tag. It's not a problem though. Just change the tag markup to add the extra div. It takes longer to talk about it than it would take to do it. :P

live627

C'mon, man!  This is Simple Machines, where we argue all day and get nothing done ! :D


Shame that it's deprecated. I really like expressive markup.

Advertisement: