错误asp:赋值后文字改变位置标签html?

时间:2011-04-16 15:01:18

标签: asp.net

    <asp:Literal ID="literal" runat="server"  >
         </asp:Literal>

我使用字符串的值低于

<div class="TopNewsTab">
    <div class="news-category">
        <div class="c1">
            <div class="c11">

            </div>
            <div class="c12" />
            <div class="c13" />
        </div>
        <div class="news-content">
        </div>
     </div>

    <div class="news-category">
        <div class="c1">
            <div class="c11">

            </div>
            <div class="c12" />
            <div class="c13" />
        </div>
        <div class="news-content">
        </div>
     </div>

</div>

使用literal.Text = valueover;

之后

当我在页面上显示我使用firebug时看到内容变为

<div class="TopNewsTab">
    <div class="news-category">
        <div class="c1">
            <div class="c11">

            </div>
            <div class="c12" />

             **<div class="news-category">
                 <div class="c1">
                   <div class="c11">

                  </div>
                  <div class="c12" />
                  <div class="c13" />

              </div>**

        <div class="news-content">
        </div>
     </div>
        <div class="c13" />
        </div>
        <div class="news-content">
        </div>
     </div>

</div>

<div class="news-category">的位置在分配文字之前改变位置请帮我解决问题??

1 个答案:

答案 0 :(得分:1)

请勿自行关闭<div/>代码。我知道它似乎在技术上应该在XHTML中有效,但它会导致问题。

所以只需改变

<div class="c12" />
<div class="c13" />

<div class="c12" ></div>
<div class="c13" ></div>