Center Tables

Get help developing custom BBCodes or request one.
Max11
Registered User
Posts: 19
Joined: Wed Oct 23, 2024 7:40 pm

Center Tables

Post by Max11 »

Is there a way to center tables?

i tried this:

Code: Select all

[center]
[TABLE]
[TR]
[TD]Text1[/TD]
[TD]Text2[/TD]
[TD]Text3[/TD]
[TD]Text4[/TD]
[TD]Text5[/TD]
[TD]Text6[/TD]
[/TR]
[/TABLE]
[/center]
But it doesn´t work. Even not if i set the center on a other position.

The BB Code for center i use is:

Code: Select all

[center]{TEXT}[/center]
Replacement:
<span style="display: block; text-align: center;">{TEXT}</span>
Last edited by Mick on Tue Oct 29, 2024 8:20 am, edited 1 time in total.
Reason: Solved.
User avatar
Sniper_E
Registered User
Posts: 1198
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey

Re: Center Tables

Post by Sniper_E »

You need to use <span style="display: block;width: 100%;text-align: center">{TEXT}</span>
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
User avatar
Steve
Registered User
Posts: 1550
Joined: Tue Apr 07, 2009 7:48 pm
Location: Co. Durham, England
Name: Steven Clark

Re: Center Tables

Post by Steve »

A lot more control with:

Code: Select all

<div style="text-align: center;">{TEXT}</div>
@ The Chief Medical Officers guideline for men is that: You are safest not to drink regularly more than 14 units per week.
- I drank that today++ :lol: 🍺
Max11
Registered User
Posts: 19
Joined: Wed Oct 23, 2024 7:40 pm

Re: Center Tables

Post by Max11 »

Thank you guys. This BB Codes work really fine with everything else like centering Text and IMG, but not Tables.
Max11
Registered User
Posts: 19
Joined: Wed Oct 23, 2024 7:40 pm

Re: Center Tables

Post by Max11 »

I couldn´t solve it with the center tag, but here i could found something helpful.

you can center a table with:

Code: Select all

[TABLE_CENTER]{TEXT}[/TABLE_CENTER]

Code: Select all

<table style="margin:0px auto"; border="1">{TEXT}</table>
This is a solution for me.
But it´s not a solution for general alignment for tables.
I had to create a special BB Code: [TABLE_CENTER] for centering tables. The normal one: [Table] i can use for left alignment for tables, but for the right alignment there is no solution until now. It would be great to make it work with the normal align BB Codes [left] [center] [right]
User avatar
Sniper_E
Registered User
Posts: 1198
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey

Re: Center Tables

Post by Sniper_E »

In tables extension I use the same classes for tleft, tcenter and tright.

Code: Select all

/* Use with table [table=tcenter,35] to center table */
.tleft { float: left;margin-right: 6px; }
.tcenter { margin: 0 auto; }
.tright { float: right;margin-left: 6px; }
See if that will help you. Example using .tcenter on a table.
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:

Return to “Custom BBCode Development and Requests”