カテゴリ | |
---|---|
サマリ | 表組みの文字をtopにする |
バージョン | 1.4.7 |
投稿者 | yataro |
状態 | 完了 |
投稿日 | 2009-12-22 (火) 20:31:22 |
表(テーブル)の中の文字を上に持っていく方法はありますでしょうか? 現時点では改行を使って上に持っていくしかないので、どうにかできるとうれしいのですが。
文字列1 文字列2 文字列3 文字列4 | 文字列1 |
となってしまうので、右側の表の文字を上にしたいのです。
var $rowspan = 1; var $style; // is array('width'=>, 'align'=>...); + var $valign = ''; function TableCell($text, $is_template = FALSE) {
$this->style = $matches = array(); - while (preg_match('/^(?:(LEFT|CENTER|RIGHT)|(BG)?COLOR\(([#\w]+)\)|SIZE\((\d+)\)):(.*)$/', + while (preg_match('/^(?:(LEFT|CENTER|RIGHT)|(BG)?COLOR\(([#\w]+)\)|SIZE\((\d+)\)|(TOP|MIDDLE|BOTTOM)):(.*)$/', $text, $matches)) { if ($matches[1]) { $this->style['align'] = 'text-align:' . strtolower($matches[1]) . ';'; - $text = $matches[5]; + $text = $matches[6]; } else if ($matches[3]) { $name = $matches[2] ? 'background-color' : 'color'; $this->style[$name] = $name . ':' . htmlspecialchars($matches[3]) . ';'; - $text = $matches[5]; + $text = $matches[6]; } else if ($matches[4]) { $this->style['size'] = 'font-size:' . htmlspecialchars($matches[4]) . 'px;'; - $text = $matches[5]; + $text = $matches[6]; + } else if ($matches[5]) { + $this->valign = strtolower($matches[5]); + $text = $matches[6]; } } if ($is_template && is_numeric($text)) $this->style['width'] = 'width:' . $text . 'px;';
if ($this->colspan > 1) { $param .= ' colspan="' . $this->colspan . '"'; unset($this->style['width']); } + if ($this->valign != '') { + $param .= ' valign="' . $this->valign . '"'; + } if (! empty($this->style)) $param .= ' style="' . join(' ', $this->style) . '"';
if (isset($this->valign != '') {一応何度も見直したのですが、追記位置は大丈夫でした。
if ($this->valign != '') {が正しいです。(isset() を開きかけて閉じてないし、おかしな事になってる・・・)
$this->style = $matches = array(); - while (preg_match('/^(?:(LEFT|CENTER|RIGHT)|(BG)?COLOR\(([#\w]+)\)|SIZE\((\d+)\)):(.*)$/', + while (preg_match('/^(?:(LEFT|CENTER|RIGHT)|(BG)?COLOR\(([#\w]+)\)|SIZE\((\d+)\)|(TOP|MIDDLE|BOTTOM)):(.*)$/', $text, $matches)) { if ($matches[1]) { $this->style['align'] = 'text-align:' . strtolower($matches[1]) . ';'; - $text = $matches[5]; + $text = $matches[6]; } else if ($matches[3]) { $name = $matches[2] ? 'background-color' : 'color'; $this->style[$name] = $name . ':' . htmlspecialchars($matches[3]) . ';'; - $text = $matches[5]; + $text = $matches[6]; } else if ($matches[4]) { $this->style['size'] = 'font-size:' . htmlspecialchars($matches[4]) . 'px;'; - $text = $matches[5]; + $text = $matches[6]; + } else if ($matches[5]) { + $this->style['valign'] = 'vertical-align:' . strtolower($matches[5]) . ';'; + $text = $matches[6]; } } if ($is_template && is_numeric($text)) $this->style['width'] = 'width:' . $text . 'px;';vertical-align をミスタイプしたからテストで失敗していた、という事にやっと気がついたので、一応あげておきます。(本当は、これをあげるつもりだった) -- 2010-01-12 (火) 07:18:37