简体   繁体   English

使用Web表单在母版页中引导巨型机和contentplaceholder

[英]bootstrap jumbotron and contentplaceholder in Master Page using webforms

Just starting with Bootstrap and Webforms. 只是从Bootstrap和Webforms开始。

I've noticed that when using Master Pages and in the contentplaceholder when placing a jumbotron in it doesn't stretch across the width of the screen, but when placing the jumbotron in the Master Page outside the contentplaceholder it does. 我已经注意到,使用母版页以及在contentplaceholder中放置超大电子纸时,它不会在屏幕的整个宽度上延伸,但是当将巨无霸文件置于contentplaceholder之外的母版中时,它却可以。

So doing some research I found out that I can use multiples contentplaceholder, changing the style for the Jumbotron ones like this: 因此,通过进行一些研究,我发现我可以使用倍数contentplaceholder,从而改变Jumbotron的样式,如下所示:

Master: 主:

    <div style="width:100%;padding-left:0px;padding-right:0px;">
        <asp:ContentPlaceHolder ID="Jumbotron" runat="server">

        </asp:ContentPlaceHolder>
    </div>

.aspx: .aspx:

<asp:Content ID="Content2" ContentPlaceHolderID="Jumbotron" runat="server">
    <!-- Main jumbotron for a primary marketing message or call to action -->
    <div class="jumbotron">
        <div class="container">
            <h1>Hello, world!</h1>
            <p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
            <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more &raquo;</a></p>
        </div>
    </div> 
</asp:Content>

But if I want several Jumbotron in the page I'll have to create several contentplaceholder in the Master, that perhaps I even not use in others webforms using the same MasterPage. 但是,如果我要在页面中使用多个Jumbotron,则必须在Master中创建多个contentplaceholder,也许我什至不使用同一MasterPage在其他Web表单中使用。 I can also use different MasterPages, but do you guys have any idea on how to avoid this, perhaps a different way to do it? 我也可以使用不同的MasterPage,但是你们对如何避免这种情况有任何想法,也许有不同的做法吗?

This is what I found (thanks to sringland for suggest me to use developer tools) 这是我发现的(感谢sringland建议我使用开发人员工具)

Master

        <!-- For Jumbotron to work in 100% width -->
        <div style="width:100%;padding-left:0px;padding-right:0px;">
            <asp:ContentPlaceHolder ID="Jumbotron" runat="server">

            </asp:ContentPlaceHolder>
        </div>        

        <!-- For the rest of the contents -->
        <div style="width:100%;padding-left:0px;padding-right:0px;">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

            </asp:ContentPlaceHolder>

            <hr />

            <div class="container">
                <footer>
                    <p>&copy; 2015 Company, Inc.</p>                
                </footer>
            </div>            
        </div> 

The For Jumbotron to work in 100% width part is no longer needed. 不再需要让For Jumbotron to work in 100% width零件中For Jumbotron to work in 100% width I just use the same css within the main ContentPlaceHolder (ContentPlaceHolder1) and add another div with class container to the footer. 我只是在主ContentPlaceHolder(ContentPlaceHolder1)中使用相同的CSS,然后将另一个带有类容器的div添加到页脚中。

This way I'm able to use either container divs or Jumbotron in the webforms that uses that Master, like below sample: 这样,我可以在使用该Master的Web表单中使用容器div或Jumbotron,例如以下示例:

.aspx .aspx

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="container">
        <!-- Example row of columns -->
        <div class="row">
            <div class="col-md-4">
                <h2>Heading</h2>
                <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
                <p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
            </div>
            <div class="col-md-4">
                <h2>Heading</h2>
                <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p>
                <p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
            </div>
            <div class="col-md-4">
                <h2>Heading</h2>
                <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
                <p><a class="btn btn-default" href="#" role="button">View details &raquo;</a></p>
            </div>
        </div>
    </div>

    <div class="jumbotron">
        <div class="container">
            <h1>Hello, world!</h1>
            <p>This is a template for a simple marketing or informational website. It includes a large callout called a jumbotron and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
            <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more &raquo;</a></p>
        </div>
    </div> 

</asp:Content>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM