我在前台写的用Repeater遍历输出一组checkBox,代码<asp:Repeater ID="Repeater9" runat="server">
                <ItemTemplate>
                  
                    <li>
                    <asp:CheckBox ID="CheckBox1" style="width:10px" runat="server"  Text='<%#Eval("name") %>'></asp:CheckBox>
                   </li>
                 
                </ItemTemplate>
                
                </asp:Repeater>  
读取也正确了,现在的问题是显示的文字紧紧挨着框框,怎么写个样式,让框框和文字中间留点空隙CheckBox

解决方案 »

  1.   

    换一种写法
     <input type="checkbox" id="chk<%# Eval("ID")%>" value="<%# Eval("ID")%>" />&nbsp;&nbsp;<%# Eval("name")%>
      

  2.   

    margin-right写了,不好使,我这边遍历出后还要再得值,所以直接用了checkbox的text显示,后台得值好得
      

  3.   

        <style>
        .mspan input
        {
             margin-right:5px;
        }
        .mspan
        {
            margin-right:20px;
        }
        </style><asp:CheckBox ID="CheckBox1" runat="server" Text="济南" CssClass="mspan"  /><asp:CheckBox ID="CheckBox2" runat="server" CssClass="mspan" Text="山东" />
      

  4.   

    1、加个css属性即可,如<input type="checkbox" style="margin-right:50px;"/>文字
    2、参考:http://blog.csdn.net/lifen_zhang/article/details/5415768
      

  5.   

    楼上说的好使,嘿嘿,我css写错了,可不可以让文字和框框的下面对齐,现在是和上面对齐
      

  6.   


        .mspan label
        {
            font-size:12px; line-height:160%;
        }
      

  7.   

     <style>
        .mspan input
        {
             margin-right:5px;
        }
        .mspan
        {
            margin-right:20px;
            margion-bottom;    }
        </style>
    直接这么写吗,不好使呀
      

  8.   


        <style>
        .mspan input
        {
             margin-right:5px; 
        }
        .mspan
        {
            margin-right:20px;
        }
        .mspan label
        {
            font-size:12px; line-height:160%;
        }
        </style>
      

  9.   

    设置你input 的vertical-align:middle(居中)就行了
      

  10.   

    Refer:
    使用HtmlGenericControl来解决:
    http://www.cnblogs.com/insus/articles/2037385.html