- Bootstrap Site Blueprints
- David Cochran Ian Whitley
- 417字
- 2021-07-16 12:27:40
Creating responsive columns
We have three blocks of text, each with a heading, a short paragraph, and a link. In screen sizes of approximately tablet width or more, we would like this content to be laid out in three columns. In narrower screen widths, the content will organize itself in one full-width column.
Take a moment to visit and read the documentation for Bootstrap's mobile-first responsive grid. You can find it at http://getbootstrap.com/css/#grid.
In short, the grid is based on a twelve-column system. The basic class structure allows us to use a class of col-12
for full-width, col-6
for half-width, col-4
for one-third width, and so on.
With Bootstrap 3, thanks to the creative use of media queries, Bootstrap's grid can be very adept. Recall that we want our welcome message to have a single-column layout up to tablet-sized screens, and then adapt a three-column layout at approximately 768px. Conveniently, Bootstrap has a built-in breakpoint at 768px, which is the default value of its @screen-sm-min
variable. Above 768px is the medium range beginning at 992px, corresponding to a @screen-md-min
variable, then the large screen, beginning at 1200px and up. I'll refer to these as Bootstrap's small, medium, and large breakpoints.
With the small breakpoint there is a special column class that uses the formulation col-sm-
. Because we want three columns after the small breakpoint, we'll use class="col-sm-4"
. Below the small breakpoint, the elements will remain full-width. Above it, they will shift to 1/3 width and line up side by side. The full structure is given here, with paragraph contents abbreviated for clarity:
<div class="container"> <div class="row"> <div class="col-sm-4"> <h2>Welcome!</h2> <p>Suspendisse et arcu felis ...</p> <p><a href="#">See our portfolio</a></p> </div> <div class="col-sm-4"> <h2>Recent Updates</h2> <p>Suspendisse et arcu felis ...</p> <p><a href="#">See what's new!</a></p> </div> <div class="col-sm-4"> <h2>Our Team</h2> <p>Suspendisse et arcu felis ...</p> <p><a href="#">Meet the team!</a></p> </div> </div><!-- /.row --> </div><!-- /.container -->
If you're unfamiliar with the container
and row
classes, here is what they do:
- The
container
class constrains the width of the content and keeps it centered within the page - The
row
class provides the wrapper for our columns, allowing extra left and right margin for the column gutters - Both the
container
class and therow
class areclearfixed
, so that they contain floating elements and clear any previous floating elements
Now, save and refresh. With your browser width above 768px, you should see the following three-column layout take shape:

Resize your browser window below 768px, and you'll see it revert to a single column.

With our responsive grid in place, let's turn those links into clearly visible calls to action by utilizing Bootstrap's button styles.
- 網(wǎng)管員典藏書架:網(wǎng)絡(luò)管理與運維實戰(zhàn)寶典
- 數(shù)字烏托邦
- Oracle SOA Suite 11g Performance Tuning Cookbook
- 企業(yè)私有云建設(shè)指南
- 正在爆發(fā)的互聯(lián)網(wǎng)革命
- 2018網(wǎng)信發(fā)展報告
- 數(shù)字調(diào)制解調(diào)技術(shù)的MATLAB與FPGA實現(xiàn):Altera/Verilog版(第2版)
- 5G技術(shù)與標(biāo)準(zhǔn)
- 端到端QoS網(wǎng)絡(luò)設(shè)計
- 6G無線網(wǎng)絡(luò)空口關(guān)鍵技術(shù)
- 設(shè)備監(jiān)控技術(shù)詳解
- 網(wǎng)絡(luò)空間全球治理觀察
- 數(shù)據(jù)血緣分析原理與實踐
- TCP/IP基礎(chǔ)(第2版)
- 基于IPv6的家居物聯(lián)網(wǎng)開發(fā)與應(yīng)用技術(shù)