アットウィキロゴ

スタイルシートに関する覚え書きです。

とても優秀なサイトがありました。
グーグルで ”テーブル スタイルシート" で検索すると
「2step脱テーブルスタイルシートCSSレイアウト講座」

というところがヒットしました。非常に優しく解説してあり、スタイルシートのことがよくわかりました。
感謝です。

外部スタイルシートの定義の仕方、二つのスタイルシートを読み込む

<head>

<link rel="stylesheet" href="「style1.css」までのパス" type="text/css">
<link rel="stylesheet" href="「style2.css」までのパス" type="text/css">

</head>

Doctypeスイッチ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

その後metaを書く

<head>
   <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
   <meta http-equiv="content-style-type" content="text/css">
   <link rel="stylesheet" href="sample.css" type="text/css">
</head>
<title>無題ドキュメント</title>


<html>より前のスペースこれを宣言する


padding の設定で top は 2pt で bottom 2pt だとちょっとズレる感じがある。
top 2pt bottom 4pt ぐらいにした方が良かった。

この方法を使うと

    function  html_css_type(){
        while ($line = mysql_fetch_array($this->result, MYSQL_ASSOC)) {
            foreach ($line as $col_value) {
               $i = $i + 1;
                   switch ($i) {
                       case 1:
                           print "<div class=\"box1\">";
                            echo $col_value;
                            print "</div>";                          
                       break;
                       case 2:
                           print "<div class=\"box2\">";
                            echo $col_value;
                            print "</div>";                          
                       break;    
                       case 3:
                           print "<div class=\"box3\">";
                            echo $col_value;
                            print "</div>";                          
                       break;
                       case 4:
                           print "<div class=\"box4\">";
                            echo $col_value;
                            print "</div>";                          
                       break;
                   }//end switch
            }//end foreach
            $i = 0;
            print "<div class=\"space\">";
        }//end while
    }//end function

このような function を書いて それぞれの box に field を割り当てることができる。
この方法を使えば、キレイにテーブルが表示される。
それだけでなく、 form を使った時もテーブルの宣言を気にすることなく使えるし、レイアウトは css のみを気にしながらいじっていけばうまく調整されるはずである。

 

タグ:

+ タグ編集
  • タグ:
最終更新:2008年09月24日 19:03