html - index.php 中的 Yii2 全 Angular 布局

标签 html css twitter-bootstrap layout yii2

在 Yii2 中对页面进行不同布局的最佳做法是什么? 我面临的问题是 Yii2 layout/main.php 代码看起来像

<div class="container">
   <?= $content ?>
</div>

Yii2 使用 Bootstrap,我只需要在 site/index.php 中制作全宽图像。 基本上在 index.php 中我需要包装

<?= $this->render('_search') ?>

进入.container-fluid 类。

如何仅将 index.php 页面的 .container 类替换为 .container-fluid 类?

最佳答案

制作一个新的布局,例如layout-fluid.php,在controller中做

public function actionIndex()
{
    $this->layout = 'layout-fluid';
    return $this->render('index');
}

如果流体容器是您唯一需要的改变,您可以改为这样做:在索引 View 文件中添加

$this->params['fluid'] = true;

然后在布局文件中将所需的容器更改为

<div class="container<?= $this->params['fluid'] ? '-fluid' : '' ?>">

params数组是在 View 中传播信息的好地方。

关于html - index.php 中的 Yii2 全 Angular 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31745513/

相关文章:

css - 视口(viewport)元标记在移动 safari 中无效

jquery - Bootstrap 按钮和面板

javascript - 在滚动的 Rails 应用程序中缩小 Bootstrap 导航栏

javascript - postcss-import grunt 插件不工作

用于固定菜单位置的 Javascript Scrolltop

javascript - 图像是在客户端还是在服务器端呈现?

html - li 面包屑图片定位错误

css - 简单的 CSS 布局 - 我怎样才能实现这种布局,并使其易于扩展?

javascript - 如何在 JavaScript 中让二维角色跑跳

css - 如何将 Bootstrap 列溢出/扩展/渗出到视口(viewport)的边缘?