Template talk:Center

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Edit request[edit]


Please replace the current code with the below:

<includeonly><div class="center">{{{1}}}</div></includeonly><noinclude>

--fryed-peach (talk) 18:13, 29 March 2009 (UTC)

 Done -- Mentifisto 19:28, 29 March 2009 (UTC)
May somebody tell me what is the point of changing "align" to "class"? I'm just asking, because since that change has been made this template fucks up tables, so I'd rather see the edit undone. (Lord Gøn (talk) 01:12, 2 April 2009 (UTC))
Can you test Template:Center/sandbox to see if it works as you intend? --fryed-peach (talk) 05:16, 2 April 2009 (UTC)
Tested it, and it does not work as I intendead. The lines between the columns get messed up by using this template. (Lord Gøn (talk) 18:25, 2 April 2009 (UTC))
I have copied your test code to Template:Center/testcases. Could you elaborate how is it messed up? --fryed-peach (talk) 06:14, 3 April 2009 (UTC)
Well, the "Sandbox"-table looks fine, because there center/sandbox is used (whyever that makes a difference). Though in the "Original" the columns including the center-template (without the sandbox-add) move to the right. I really have a hard time to describe it. Isn't it visible for you? The lines confining the "center using"-columns overlap with the words in those columns not using it. It look really messed up and unpleasant.
It should look like this:
Column 1 | (center-template used here) Column 2 | Column 3
But by using this template it looks that way:
Column 1 | (center-template used here) Column 2 C|olumn 3
(Lord Gøn (talk) 18:58, 3 April 2009 (UTC))
Thank your for testing. The problem is not visible in my usual browser, but I see it in some browsers. --fryed-peach (talk) 15:31, 4 April 2009 (UTC)

{{editprotected}} Admin, please copy Template:Center/sandbox to Template:Center. --fryed-peach (talk) 15:31, 4 April 2009 (UTC)

Done --Amalthea 16:43, 4 April 2009 (UTC)

Doc updates[edit]

{{Left}} and {{left2}} are table cell alignment templates and have nothing to do with {{center}} or {{right}}.

The example table has not context, thus is useless.

Class center[edit]

The template is currently defined as:

<div class="center" style="width:auto; margin-left:auto; margin-right:auto;">...</div>

center is defined in mediawiki.skinning/elements.css:

/* Emulate Center */
.center {
 width: 100%;
 text-align: center;

*.center * {
 margin-left: auto;
 margin-right: auto;

The problem with class=center alone is that it sets width: 100%; which is often undesirable. The template overrides this with width: auto;.

Seems to me this would be simpler as:

<div style="text-align: center; width:auto; margin-left:auto; margin-right:auto;">...</div>

--  Gadget850 talk 23:13, 5 March 2015 (UTC)

You probably mean without the margins. -- [[User:Edokter]] {{talk}} 00:18, 6 March 2015 (UTC)
I was just considering that. What would be your recommendation? Would it be better to add a new class? --  Gadget850 talk 00:49, 6 March 2015 (UTC)
Depends what we want from this template; If we want to center a block, like {{left2}} and {{right}} which uses float, then this template should not be changed. If however you only want just to center text inside a block, then there should only be text-align: center;. The whole naming is a bit inconsistent. -- [[User:Edokter]] {{talk}} 09:13, 6 March 2015 (UTC)
I'm thinking this should be used only to center a block of text. --  Gadget850 talk 09:21, 6 March 2015 (UTC)

Protected edit request on 18 March 2015[edit]

please update to use the code in this version of the sandbox, which is equivalent to making this change. basically, it adds tracking for the case when the input is blank or missing, which would be pointless, since the template generates an empty div in that case. this is also (sometimes) useful for tracking cases when there is an unescaped = in the input. Frietjes (talk) 16:05, 18 March 2015 (UTC)

 Done. -- [[User:Edokter]] {{talk}} 16:15, 18 March 2015 (UTC)

Update to match left and right[edit]

currently, the {{left}} and {{right}} templates do two slightly different things, depending on if they are passed an unnamed input. for example (see the code)

Method 1
left text default text right text
Method 2
left text
default text
right text

I propose to update this template to this version which will make the syntax match {{left}} and {{right}}. since Category:Pages using center with no arguments is empty, this would cause no change in existing transclusions. comments or suggestions? Frietjes (talk) 15:04, 14 July 2015 (UTC)

since there are no objections, please update this template to this version of the sandbox. Frietjes (talk) 15:08, 12 October 2015 (UTC)
@Frietjes: I don't know, the no-parameter usage looks like a pretty horrible hack to me. If this is used in wikitables, won't it stop them from being editable with VisualEditor? — Mr. Stradivarius ♪ talk ♪ 10:27, 13 October 2015 (UTC)
User:Mr. Stradivarius, if this syntax breaks something, then someone should add tracking and clean up all uses with {{left}}/{{right}}. the proposal is for syntax consistency. Frietjes (talk) 14:16, 13 October 2015 (UTC)
The current code is horrid, so is the proposed code. Can't we decide first what it is supposed to do, then work from there, instead of the other way around? -- [[User:Edokter]] {{talk}} 19:16, 13 October 2015 (UTC)
User:Edokter, so what is your proposal? Frietjes (talk) 16:04, 8 November 2015 (UTC)
First we should define the desired functionality that does not have any ambiguity. -- [[User:Edokter]] {{talk}} 22:34, 8 November 2015 (UTC)
so only method 2? or only method 1? Frietjes (talk) 15:52, 21 November 2015 (UTC)

Learning how to center a template[edit]

It would be really helpful if at the top of the page there was a link to learn how to have the output of the template center on the page, I can't find this information and I keep coming back to this page.


Mrjohncummings (talk) 14:36, 15 September 2015 (UTC)

Template-protected edit request on 3 May 2016[edit]

Smarttechagra (talk) 07:17, 3 May 2016 (UTC)

Red information icon with gradient background.svg Not done: Empty request — Andy W. (talk ·ctb) 07:55, 3 May 2016 (UTC)

Redundant styles?[edit]

It appears that all the CSS declarations in this template's style attribute do nothing. Auto width on a div is the same as default, 100%. The margins are redundant with the center class. Would it be safe to just delete these declarations? See sandbox and testcases.

While I'm at it, neither the live nor sandbox version works on mobile. Perhaps a quick and dirty text-align:center might patch it up until TemplateStyles is in? Matt Fitzpatrick (talk) 02:51, 27 August 2017 (UTC)