【问题标题】:How do you stop RadioButtonList Label text from wrapping under the button如何阻止 RadioButtonList 标签文本在按钮下换行
【发布时间】:2010-10-24 17:53:38
【问题描述】:

我有一个单选按钮列表,其中一些标签很长,所以它们会换行,第二行出现在单选按钮下方。理想情况下,我希望文本从第一行的第一个字符下方开始的第二行换行。

有什么想法吗?还是我必须为此创建自己的基于列表的控件?

【问题讨论】:

    标签: asp.net layout webforms


    【解决方案1】:

    如果有人无法让所选答案正常工作:它仅在您的 RadioButtonList 使用 RepeatLayout="Table" 而不是 RepeatLayout="Flow" 时才有效。我花了一分钟才明白这一点。

    【讨论】:

      【解决方案2】:

      我知道这有点晚了,但这对我有用:

          table.NoWrapRadio td
          {
              white-space:nowrap;
          }
      

      当我使用所选回答者的方法时,包装问题得到了解决,但它使单选按钮呈现的 vew 像素低于标签。我正在使用 IE9 兼容模式。

      【讨论】:

        【解决方案3】:

        尝试负文本缩进样式 -20px 适用于 IE8

        【讨论】:

          【解决方案4】:

          这个 CSS 确实有效:

          <style type="text/css">
           table.radioWithProperWrap input
           {    
                float: left;
           }
          
           table.radioWithProperWrap label
           {    
                margin-left: 25px;
                display: block;
           }
          </style>
          <asp:RadioButtonList runat="server" CssClass="radioWithProperWrap" ....>
          

          【讨论】:

          • 非常感谢,我有一个适用于 IE 的类似样式,只是对要强制显示的元素进行排序:当你一针见血时阻止。
          【解决方案5】:

          您可以使用单选按钮和单独的标签并设置该标签的AssociatedControlID 属性。

          <table>
              <tr>
                  <td>
                      <asp:RadioButton runat="server" ID="rdo" />
                  </td>
                  <td>
                      <asp:Label runat="server" ID="lbl" Text="Radio Text" AssociatedControlID="rdo" />
                  </td>
              </tr>
          </table>
          

          【讨论】:

          • 谢谢,我希望不必做更多的表格布局,所以我将采用风格理念。
          猜你喜欢
          • 2017-07-05
          • 1970-01-01
          • 1970-01-01
          • 2022-12-06
          • 1970-01-01
          • 2020-04-08
          • 1970-01-01
          • 2017-12-28
          • 2012-05-27
          相关资源
          最近更新 更多