【问题标题】:Best Practice -- Create Bootstrap template with 3 columns -- Left & Right Sidebars最佳实践——创建具有 3 列的 Bootstrap 模板——左侧和右侧边栏
【发布时间】:2017-11-26 07:15:56
【问题描述】:

我想要一种简单的方法来创建一个三列引导模板,该模板将具有 (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>

另外,我知道我可以在每一页上做这样的事情 例如 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 来将侧边栏保持在各自的左右位置。

我宁愿对所有三列都使用核心 Bootstrap,而无需编写额外的 CSS 或 JS。请帮忙?

【问题讨论】:

    标签: javascript php css twitter-bootstrap templates


    【解决方案1】:

    将您的 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>
    

    【讨论】:

    • 哦,哇,我笑了,到底为什么我想不通呢?感谢您帮助我@James
    • 不用担心,很高兴它有帮助:)
    猜你喜欢
    • 2014-10-15
    • 2012-02-04
    • 1970-01-01
    • 2012-12-04
    • 2015-09-27
    • 1970-01-01
    • 2018-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多