douan9541 2015-10-21 19:03
浏览 88

在Yii2上添加materializecss中的完整css和文件

after my latest question about adding it in Yii2, here is my AppAsset:

<?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace frontend\assets;

use yii\web\AssetBundle;

/**
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'css/materialize.css',
        'css/materialize.min.css',
    ];
    public $js = [
        'js/materialize.js',
        'js/materialize.min.js',
    ];
    public $depends = [
        # 'yii\web\YiiAsset',
        # 'yii\bootstrap\BootstrapAsset',
    ];


}

And this is the structure of those files i've added before.:

enter image description here

as you can see, i've just added css`s and js files without font and icons.

So, what should i do else?

the template is a little bit like materialize, but still i think it's has a problem, see:

enter image description here

if there are many things to do, please guide me to do this and let it go.

also, it was on the view:

use common\widgets\Alert;
use frontend\assets\AppAsset;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\helpers\Html;
use yii\widgets\Breadcrumbs;

AppAsset::register($this);

Cheers!

  • 写回答

1条回答 默认 最新

  • dqd22496 2016-10-01 13:59
    关注

    Frist uncoment the 'yii\web\YiiAsset' and second use only the min version of the css and js, and add in your app asset css 'http://fonts.googleapis.com/icon?family=Material+Icons'

    And the last your nav bar need to be something like that

    <nav>
      <div class="nav-wrapper">
        <a href="#" class="brand-logo">my company</a>
        <a href="#" data-activates="mobile" class="button-collapse"><i class="material-icons">menu</i></a>
        <ul id="nav-mobile" class="right hide-on-med-and-down">
          <li><a href="<?= Url::toRoute("site/index")?>">Home</a></li>
          <li><a href="<?= Url::toRoute("site/stuff")?>">Stuffs</a></li>
        </ul>
        <ul class="side-nav" id="mobile">
         <li><a href="<?= Url::toRoute("site/index")?>">Home</a></li>
         <li><a href="<?= Url::toRoute("site/stuff")?>">Stuffs</a></li>
      </ul>
      </div>
    </nav>
    

    Other easy way to do this is installing materialize css theme for yii2 using composer :)

    评论

报告相同问题?

悬赏问题

  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭