**[[質問箱4/540]] [#z2a3c2c0]
#author("2018-03-11T20:54:12+09:00;2010-01-12T07:18:37+09:00","","")
**[[質問箱/4540]] [#z2a3c2c0]
|RIGHT:70|LEFT:410|c
|~カテゴリ||
|~サマリ|表組みの文字をtopにする|
|~バージョン|1.4.7|
|~投稿者|[[yataro]]|
|~状態|完了|
|~投稿日|&new{2009-12-22 (火) 20:31:22};|
***質問 [#x2ee240f]
表(テーブル)の中の文字を上に持っていく方法はありますでしょうか?
現時点では改行を使って上に持っていくしかないので、どうにかできるとうれしいのですが。

|文字列1&br;文字列2&br;文字列3&br;文字列4|文字列1|

となってしまうので、右側の表の文字を上にしたいのです。

***回答 [#f58e6561]
- [[質問箱3/343]] --  &new{2009-12-23 (水) 03:29:24};
- [[質問箱/3343]] --  &new{2009-12-23 (水) 03:29:24};
- wiki 全体で固定するなら、CSS を設定すればできます。表やセルごとに変えたい場合は、改造しないとできません。&br;lib/convert_html.php 1.18基準で
--485行目あたり
  	var $rowspan = 1;
  	var $style; // is array('width'=>, 'align'=>...);
 +	var $valign = '';
  
  	function TableCell($text, $is_template = FALSE)
  	{
--490行目あたり
  		$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;';
--545行目あたり
  		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) . '"';
- 
と改造すれば、TOP:, MIDDLE:, BOTTOM: のルールを追加できるはず。 --  &new{2009-12-23 (水) 03:58:41};
- wiki全体ではなく、上記改造の通りで指定したいと思っていました。早速やってみたのですが画面がエラーの真っ白になってうまくいきませんでした。&br;[[質問箱4/243]]の改造をしているのですが、それが原因なのでしょうか? -- [[yataro]] &new{2009-12-24 (木) 01:06:30};
- wiki全体ではなく、上記改造の通りで指定したいと思っていました。早速やってみたのですが画面がエラーの真っ白になってうまくいきませんでした。&br;[[質問箱/4243]]の改造をしているのですが、それが原因なのでしょうか? -- [[yataro]] &new{2009-12-24 (木) 01:06:30};
- ぱっと見では、それだけだと干渉しないハズなので、追記位置がずれてパースエラー(構文エラー)になってるだけだとは思うんですが・・・。[[Q. 設置後にアクセスすると画面が真っ白になって、エラーメッセージが何も表示されない>Q&A/インストール#x80b2883]] を参考に、エラーを確認してみては?(ただ、PHP 5 なら[[dev:BugTrack2/146]] のエラーとかまで、表面化するかもしれませんが) --  &new{2009-12-24 (木) 02:31:10};
- ログににとって試したところ、この行でエラーがでていました。
 if (isset($this->valign != '') {
一応何度も見直したのですが、追記位置は大丈夫でした。&br;他に何かと干渉しているののもしれませんが、このエラーで何か分かることはありますでしょうか? -- [[yataro]] &new{2009-12-25 (金) 06:15:03};
- すみません、おもいっきりゴミがついてます。上のは直しましたが
 if ($this->valign != '') {
が正しいです。([[isset()>PHP関数:isset]] を開きかけて閉じてないし、おかしな事になってる・・・)&br;差分を作り直した時に、混じったようです。手元では直してるのにコッチに反映させ忘れたまま、という状態に気がついていなかった・・・ --  &new{2009-12-25 (金) 11:05:09};
- おお、ありがとうございます。文字が上にくるようになりました。&br;この機能はデフォルトであると思っていたのですが、質問してよかったです。また1つwikiの編集が便利になりました。&br;間違いの修正なども本当にありがとうございました。 -- [[yataro]] &new{2009-12-26 (土) 04:18:42};
- CSS ファイルの設定を上書きできるstyle 属性版を。&br;lib/convert_html.php 1.18 のデフォルト基準で490行目あたり
  		$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 をミスタイプしたからテストで失敗していた、という事にやっと気がついたので、一応あげておきます。(本当は、これをあげるつもりだった) --  &new{2010-01-12 (火) 07:18:37};

//#comment

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Site admin: PukiWiki Development Team

PukiWiki 1.5.4+ © 2001-2022 PukiWiki Development Team. Powered by PHP 8.2.12. HTML convert time: 1.086 sec.

SourceForge