0

以下に示すようなスクリプトがあります。

#header2 {
    align:center;
    text-align:center;
    font-size: 24px;
        color:red;
    }
  #column {
    width:100%;
 }


.Lcol1 {
     float:left;
     width:16.5%;

 }




  .Lcol2 {
float:left;
     position: relative;
     width:16.5%;

 }


  .Lcol3 {
float:left;
     position: relative;
     width:16.5%;

 }


  .Lcol4 {
float:left;
     position: relative;
     width:16.5%;

 }



  .Lcol5 {
float:left;
     position: relative;
     width:16.5%;

 }


  .Lcol6 {
float:left;
     position: relative;
     width:
}

<div id="columns">
<span class="col1">
<?php
$i=1;
while ($i<$other) {
echo "text1";
    }
?>
</span>
<span class="col2">
<?php
$i=1;
while ($i<2) {
echo "text2";
    }
?>
</span>
<span class="col3">
<?php
$i=1;
while ($i<2) {
echo "text3";
    }
?>
</span>
<span class="col4">
<?php
$i=1;
while ($i<2) {
echo "text4";
    }
?>
</span>
<span class="col5">
<?php
$i=1;
while ($i<2) {
echo "text5";
    }
?>
</span>
<span class="col6">
<?php
$i=1;
while ($i<2) {
echo "text6";
    }
?>
</span>
</div>

<div id="header2">
header2
</div>`enter code here`

問題は、「header2」がまだ列に印刷されていることです。列を 1 つずつ削除しても、ヘッダーは列に印刷されたままですか? なぜ?PHPコードがなくても問題なく動作しますが、データをエコーするにはPHPが必要です。PHP がここで html を台無しにするのはなぜですか?

4

2 に答える 2

1

css プロパティ "float" を使用して列を作成しましたか? もしそうなら、あなたの "columns" div と "header2" div の間にこれを入れてみてください:

<div style="clear:both"></div>

しかし、CSS がないと問題を確認するのは困難です...

于 2013-05-15T13:33:21.910 に答える
0

ここでは、いくつかの CSS を提供すると便利です。

私の推測では、PHP を使用していないときはコンテンツがなく、ヘッダーが列に表示されていないためです。それ以外の場合は、結果の html を確認してください。これは、PHP 関連というよりも、CSS または適切な HTML 構造化の問題のようです。

オフレコ: エコーに「while」を使用する理由は、私には謎のままです。

于 2013-05-15T13:30:40.067 に答える