首頁  >  文章  >  web前端  >  Twitter Bootstrap 是否可用於建立具有固定寬度側邊欄和流動寬度主要內容區域的兩列佈局?

Twitter Bootstrap 是否可用於建立具有固定寬度側邊欄和流動寬度主要內容區域的兩列佈局?

Mary-Kate Olsen
Mary-Kate Olsen原創
2024-11-14 22:01:02221瀏覽

Can Twitter Bootstrap be used to create a two-column layout with a fixed-width sidebar and a fluid-width main content area?

Creating a 2 Column (Fixed - Fluid) Layout with Twitter Bootstrap

In this article, we'll delve into whether it's feasible to achieve a two-column layout with a fixed-width sidebar and a fluid-width main content area using Twitter Bootstrap. We'll provide comprehensive explanations and solutions to guide your development.

Is it Possible with Twitter Bootstrap?

Twitter Bootstrap initially included a fixed-fluid layout option through the ".container-fluid" class. However, with the release of version 2.0, this feature was removed. Hence, it's not possible to implement a fixed-fluid layout solely using the standard Bootstrap classes.

Solution

1. Fixed-Fluid Layout

We can implement a fixed-fluid layout using a combination of modified HTML and CSS:

HTML:

<div>

CSS:

.fixed {
    width: 150px;
    float: left;
}

.fixed + div {
     margin-left: 150px;
     overflow: hidden;
}

html, body {
    height: 100%;
}

.fill { 
    min-height: 100%;
    position: relative;
}

.filler::after{
    background-color:inherit;
    bottom: 0;
    content: "";
    height: auto;
    min-height: 100%;
    left: 0;
    margin:inherit;
    right: 0;
    position: absolute;
    top: 0;
    width: inherit;
    z-index: -1;  
}

2. Equal Column Heights (Optional)

To achieve equal heights for the sidebar and content area:

HTML:

<div>

Notes:

  • To make the sidebar the filler element, change "right: 0" to "left: 0" in the CSS.

以上是Twitter Bootstrap 是否可用於建立具有固定寬度側邊欄和流動寬度主要內容區域的兩列佈局?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn