Template talk:Block center

From Wikisource
Jump to: navigation, search

Which is better—a hack that works, or an elegant solution that doesn't? I think someone's bad hand sockpuppet should convert this to use tables. Hesperian 11:56, 27 October 2008 (UTC)

Why don't we use a div with align:auto; display:table;? Then we don't need to hack tables to get this result. Am I missing something? You can put the width in the style as well, then you can use percentages as well:
<div  style="width:{{{width|auto}}}; margin:auto; display:table; background:inherit; text-align:{{{align|left}}};">

It seemed to work when I tried it, but I'm not sure if I missed something. Mock up of the template at User:Inductiveload/Sandbox6 and example of use at User:Inductiveload/Sandbox7. Inductiveloadtalk/contribs 15:18, 22 February 2011 (UTC)

It works for you because you're using a decent browser. Try it in IE7. Hesperian 23:38, 22 February 2011 (UTC)
Good point, I knew there was probably a reason we did it this way, I just wanted to check. So, next step: eradicate IE. I'm not sure if that should go above or below world hunger. Inductiveloadtalk/contribs 04:30, 23 February 2011 (UTC)

Optional width component?[edit]

This works nicely in poetry/inserted, especially where it interrupts the flow of a work. However, I have come across situations where it is not quite wide enough and causes some wrapping. I was thinking that an optional width option to force the table column wider would be useful. Initially leaving a note here in case of any concerns/issues. — billinghurst sDrewth 10:39, 17 May 2010 (UTC)

I've noticed that too. The only problem is that fixing the width breaks the centering; i.e. if you fix the width at 40%, then the "centred" text will start at 30% (i.e. (100-40)/2 ) regardless of its actual width. Hesperian 11:16, 17 May 2010 (UTC)
Yep, and I know it will be a little bit of trial and error, ie. try au natural then add a value and incrementally +/- until the minimum disperse effect achieved. Only other option that I saw was a margin-left, and that gets hosed once you get variations in screen width.Plus you can give it a fixed width with px measure, rather than a %width. — billinghurst sDrewth 12:33, 17 May 2010 (UTC)
Stuck it in and it can be reverted if required. width and add in px or em. — billinghurst sDrewth 13:22, 17 May 2010 (UTC)