【问题标题】:Twitter Bootstrap `container` divs in ASP.Net WebFormsASP.Net WebForms 中的 Twitter Bootstrap `container` div
【发布时间】:2012-07-03 16:13:48
【问题描述】:

我在Several containers at one pageTwitter Bootstrap Containers 中找到了一些关于container 使用的信息,但我希望得到更多信息。

从 Twitter Bootstrap 自己的示例中,我们在同一页面上看到多个 container div。但是 ASP.Net MasterPages 和 UserControls 呢?

是否应该在 Master 上使用单个 container,因此将所有内容区域包含在单个顶级 container 中(然后内容页面将由 row div 组成)?还是应该将container div 下推到内容页面?

更进一步,由几个row div 组成的相当复杂的UserControl (.ascx) 怎么样? ascx 标记应该有自己的container,还是以row div 开头,假设包含页面有一个封闭的container

最后,更一般地说,是否有人对何时使用新的container div 有一个经验法则?

【问题讨论】:

    标签: asp.net webforms twitter-bootstrap


    【解决方案1】:

    我将容器 div 放在我的母版页中,因为我的所有页面都将使用子页面中的行/跨度。万一我希望我的子页面不使用容器,我只需关闭 div 标签...

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
      </div> <!-- ending the container -->
    
      <!-- whatever -->
    
      <div> <!-- the master page ends the container div, so we'll add this instead -->
    </asp:Content>
    

    一些关于 bootstrap 和 asp.net 的有用提示...

    单选按钮和复选框。 文本出现在单选框/复选框下方。通过将您的 asp.net 单选按钮列表控件或类似控件嵌套在具有 radio css 类或 checkbox css 类的 div 中,并将 RepeatLayout 设置为 flow 来解决此问题。

    <div class="radio">
        <asp:RadioButtonList ID="rblFleettype" runat="server" RepeatLayout="Flow">
            <asp:ListItem Selected="True">Item 1</asp:ListItem>
            <asp:ListItem>Item 2</asp:ListItem>
        </asp:RadioButtonList>
    </div>
    

    错误消息警报。 许多 asp.net 控件可以转换为模板以暴露错误文字/标签,然后您可以将CssClass="alert alert-error" 应用于错误标签。但是如果你这样做,即使还没有错误,它也会显示红色的错误边界。要解决这个问题,您可以使用文字/标签的 PreRender 事件来检查 Text 属性并查看它是否为空,然后相应地设置 Visibility 属性。

    【讨论】:

    • 感谢您在内容页面上关闭container 的提示。以及有关 asp.net 控件的大量附加信息。 WRT Bootstrap containers,对于嵌套container div 是否可以,或者将container 保持在“外”级别是否更好?
    • 我认为是外层。 container 类具有 width: 940px; 属性。因此,将其嵌套在任何小于 span12 的内容中可能不是一个好主意。您可以将行嵌套在其他行中,example。如果你想在span## 中嵌套一个容器,bootstrap 有container-fluid。你可以用它来嵌套你想要的所有东西。您可以查看上面那个链接中的用法。
    • 非常感谢。我现在有我需要的东西。
    猜你喜欢
    • 2011-12-28
    • 2012-12-17
    • 1970-01-01
    • 2012-11-16
    • 1970-01-01
    • 2012-04-28
    • 2012-09-03
    • 2013-01-26
    • 1970-01-01
    相关资源
    最近更新 更多