[TYPO3-content-rendering] Proposed fix for image alignment and Firefox/Mozilla
Martin Kutschker
Martin.Kutschker at n0spam-blackbox.net
Fri Oct 28 13:52:51 CEST 2005
Hi!
I guess that few on this list use the default css_styled_content
implementation of image ot text w/image, but anyway here comes a fix
for it.
The problem is that the image alignment above or below text is broken in
Firefox/Mozilla. The reason is that
<div style="text-align: right"><table>...</table></div>
won't work. To make it work you have to set margins on the table
<table style="margin-left: auto; margin-right: 0px">...<table>
For centering you need to set both margins to auto, for left alignment
the left margin is 0 and the right auto.
Fortunatley you can mix both settings. So I have come up with a solution
that works for me in IE 6 and Firefox.
function IMGTEXT($conf) {
...
if ($c) {
// Table-tag is inserted
// OLD CODE
// $i=$contentPosition;
// $table_align = (($i==16) ? 'align="'.$align.'"' : '');
switch ($contentPosition) {
case '0': // above
case '8': // below
// these settings are needed for Firefox
switch ($align) {
case 'left':
$table_align = 'margin-left: 0px; margin-right: auto';
break;
case 'center':
$table_align = 'margin-left: auto; margin-right: auto';
break;
case 'right':
$table_align = 'margin-left: auto; margin-right: 0px';
}
$table_align = 'style="'.$table_align.'"';
break;
case '16': // in text
$table_align = 'align="'.$align.'"';
break;
default:
$table_align = '';
}
...
}
I'm not sure if it's needed to set the margins to 0px (if not auto). The
default values may be enough. And without it yo still can set the a
(default) margin with CSS.
What do you think of that solution?
Masi
More information about the TYPO3-project-content-rendering
mailing list