最佳实践 - 使用3列创建Bootstrap模板 - Left&右边栏

时间:2017-11-26 07:15:56

标签: javascript php css twitter-bootstrap templates

我想要一种简单的方法来创建一个三列引导程序模板,它将包含(1)左侧边栏,(2)中间/主要内容区域和(3)右侧边栏。

虽然我不难在一个页面中创建3个引导列,但我的问题是如何在每个页面中包含相同的左右侧边栏。

我知道我可以像这样在一个页面中创建3列

<div class = "container">
<div class = "row">
<div class = " col-lg-3"> Left column</div>
<div class = "col-lg-6"> Main/Middle column </div>
<div class = col-lg-3" Right column </div>
</div>
</div>

另外,我知道我可以在每一页上做这样的事情 E.g index.php

<?php include 'left_sidebar.php' ?>

<div class = "container">
<div class = "row">
<div class = "col-lg-12"> Middle/main content area</div>
</div>
</div>

<?php include 'right_sidebar.php' ?>

其中left_sidebar.php和right_sidebar.php各包含一列。

然而,这需要我编写一些CSS和一些JS来将侧边栏保持在各自的左右位置。

我更喜欢在没有编写额外的CSS或JS的情况下为所有三列使用核心Bootstrap。有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

将你的php包含在你的col-3 div中。

<div class = "container">
 <div class = "row">
  <div class = " col-lg-3"> 
   <?php include 'left_sidebar.php' ?>
  </div>
  <div class = "col-lg-6"> 
    Main/Middle column
  </div>
  <div class = col-lg-3">
  <?php include 'right_sidebar.php' ?>
  </div>
 </div>
</div>