簡體   English   中英

Bootstrap Jumbotron 沒有變成 Body 的全寬

[英]Bootstrap Jumbotron not becoming full width of Body

嗨,我正在嘗試將我的 Jumbotron 修復為屏幕的全寬,但不知何故它需要一個15px padding-left, padding-right 如果我移除內邊距,水平滾動條就會出現 30 30px right margin 我使用的是默認的 Bootstrap 版本 3.0.3 和默認的 VS2013 布局。 根據此鏈接,我刪除了所有.container之外的 Jumbotron 我的頁面看起來像這樣

<body>
<div class="navbar navbar-inverse navbar-fixed-top">.... Navigation stuff</div>
<div class="jumbotron specialjum">
<div class="over container body-content">
....page headers and other stuff
</div>
</div>
<p class="just container body-content">
... body text
</p>
</body>

/////////////////////////////////////////////////

body {
padding-top: 50px;
padding-bottom: 20px;
/*background:url("../Images/ps_neutral.png") repeat;*/
}
                    
/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
.just {
text-align: justify;
}
.specialjum {
background: url('http://fc00.deviantart.net/fs70/i/2013/339/7/1/princess_kenny_korosu_by_theshadowstone-d6wu2zo.png') center;
color:#fff;
background-size: cover; 
}

編輯: Firefox + Chrome + IE10 結果 ===|==================|===

關於如何修復布局的任何想法? 我還沒有接觸過使用 Nuget 更新的 Bootstrap CSS。

只是為了分享我在 Visual Studio 2013 中創建 MVC Web 應用程序后的經驗,無論我做什么,我都無法讓超大屏幕拉伸屏幕的寬度。 我最終發現它被 Views/Shared/_Layout.cshtml 頁面上的默認 **container body-content 標簽阻止。 刪除標簽后,它顯示正確。 希望能幫助到和我有類似情況的人。

代碼

之前

后

解決辦法很簡單。 這就是我如何划分它:

    <body>
    <div class="navbar navbar-inverse navbar-fixed-top">.... Navigation stuff</div>
    <div> <===================this Div wrapping jumbotron
    <div class="jumbotron specialjum">
    <div class="over container body-content">
    ....page headers and other stuff
    </div>
    </div>
    <p class="just container body-content">
    ... body text
    </p>
    </div>
    </body>

CSS 的任何部分都沒有更改。 我不知道它為什么有效,但它確實有效。

如果您只是想刪除填充,那么您需要放置padding:0; 在您的.specialjum ,並確保在引導程序之后調用自定義樣式表。 否則添加padding:0!important; 如果之前需要調用。 同樣對margin-right:重復此操作,並添加width:100%; 如果它沒有延伸到我認為應該已經達到的頁面寬度。

看到這個jsFiddle

對於可能會在這里結束的其他人,我有一個替代解決方案。 我遇到了這個問題,但我無法將我的 Jumbotron 帶出它的容器。 我所做的只是將它包裝在一個<div class="row"></div> 我仍在學習引導程序,所以我不知道這是否會導致任何問題,但現在它工作得很好。

為了使jumbotron全寬且沒有圓角,請將其放置在所有 .containers 之外,而是在其中添加一個 .container。

_Layout.cshtml 中的另一個選項(其中“主頁”是您想要全寬的頁面):

@if (ViewData["Title"].Equals("Home"))
{
    @RenderBody()
}
else
{
    <div class="container container-main">
        <main role="main">
            @RenderBody()
        </main>
    </div>
}

.container寬度更改為 100%:

container { width: 100% }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM