Css和bootstrap在yii2 [英] Css and bootstrap in yii2

查看:113
本文介绍了Css和bootstrap在yii2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Yii2很新,我创建了一个布局页面,但我的CSS不能完全工作。它只加载它的一部分。有人可以帮我吗?

I'm quite new to Yii2 and I have created a layout page, but my CSS doesn't work fully. It only loads parts of it. Can somebody help me please?

我的布局:

<?php
namespace app\views\layouts;

use yii\bootstrap\Alert;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\helpers\Html;
use yii\bootstrap\NavBar;
use yii\bootstrap\Button;
use app\models\Search;
use yii\bootstrap\Nav;
use app\assets\AppAsset;
use app\models\LoginForm;
use yii\web\View;
use Yii;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="language" content="en" />
    <?= Html::csrfMetaTags() ?>
    <title><?php echo Html::encode($this->title); ?></title>

    <link rel="shortcut icon" href="<?php echo Yii::getAlias('@web/themes/dcu') ?>/assets/images/favicon.png" type="image/x-icon" />


     <link rel="stylesheet" type="text/css" href="<?php echo Yii::getAlias('@web'); ?>/themes/dcu/assets/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::getAlias('@web'); ?>/themes/dcu/assets/css/bootstrap-responsive.min.css" />
       <link rel="stylesheet" type="text/css" href="<?php echo Yii::getAlias('@web'); ?>/themes/dcu/assets/css/gbu.csss" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::getAlias('@web'); ?>/themes/dcu/assets/css/font-awesome.css" />

<?php $this->head()?>
</head>
<body>
    <?php $this->beginBody() ?>
    <span class="striept"></span>
    <div id="wrap">
        <div class="container" id="page">
            <div class="row header">
                <div class="span7">
                    <a href=<?php Yii::$app->homeUrl ?>><img src="<?php echo Yii::getAlias('@web'); ?>/themes/dcu/assets/images/documentatiecentrum-urk.png" /></a>
                </div>
                <div class="span5 login-form">
                    <?php if (Yii::$app->user->isGuest): ?>
                        <div class="form">
                        </div>
                    <?php else: ?>
                        <ul class="inline">
                            <li>Je bent inlogd als: <?php echo Yii::$app->user->identity->username; ?> </li>
                            <li>
                            </li>
                        </ul>
                    <?php endif; ?>
                </div>
            </div>
            <div class="row">
                <div class="span12 zoeken">
                    <div class="input-append">

                    </div>
                </div>
            </div>

        </div>

        <div class="container-fluid dark topmargin">
            <div class="container">
                <div class="row">
                    <div class="span8">
                        <h3>Onze partners</h3>
                        <div class="row-fluid">
                            <div class="span4">

                            </div>
                            <div class="span4">

                            </div>
                            <div class="span4">

                            </div>
                        </div>
                    </div>
                    <div class="span4">
                        <div class="row-fluid">
                            <h3>Ook meehelpen?</h3>
                            <p>Met uw steun zorgt u er samen met ons voor dat ons grote cultuurbezit, 'oenze taol', blijft bestaan!</p><p>Steun ons project en doneer een bedrag op onze bankrekening: 11.40.24.820 Rabobank Urk. Bedankt voor uw hulp!</p>
                            <a class="btn btn-primary" href="https://www.justgiving.nl/nl/charities/83-stichting-%20urker-taol" target="_new">Direct doneren</a>
                            <a class="btn btn-primary" href="<?php echo Yii::$app->basePath; ?>donateursformulier.pdf" target="_new">Donateursformulier</a>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="span12 copyright">
                    </div>
                </div>
            </div>
        </div>
    </div>
   </body>
    <?php $this->endBody() ?>
</html>
<?php $this->endPage() ?>

我认为问题是bootsrap,因为所有其他的CSS文件都可以。

I think the problem is the bootsrap, because all the other CSS files are all OK.

推荐答案

AssetBundle 代表一组资产文件,例如CSS,JS等。

AssetBundle represents a collection of asset files, such as CSS, JS, etc.

资产包可以依赖于其他资产包。在注册包含视图的资源包时,其所有相关资产包都将自动注册。

An asset bundle can depend on other asset bundles. When registering an asset bundle with a view, all its dependent asset bundles will be automatically registered.

请参阅以下链接

Yii2 AssetBundle API DOC

AssetBundle示例

首先创建一个 ThemeAsset AssetBundule。

First create one ThemeAsset AssetBundule.

<?php

    namespace app\assets;
    use yii\web\AssetBundle;

    class ThemeAsset extends AssetBundle
    {
        public $basePath = '@webroot';
        public $baseUrl = '@web';
        public $css = [
             '/themes/dcu/assets/css/bootstrap.css',
             '/themes/dcu/assets/css/bootstrap-responsive.min.css',
             '/themes/dcu/assets/css/gbu.css',
             '/themes/dcu/assets/css/font-awesome.css',
        ];
        public $js = [      
             .... 
             js file here
             .... 
        ];
        public $jsOptions = [
             ....
             js options here
             ....
        ];
        public $depends = [
             ....
             dependent asset bundles here
             eg: 'yii\bootstrap\BootstrapAsset'
             ....
        ];
    }
?>

现在注册查看文件

<?php
   use app\assets\ThemeAsset;
   ThemeAsset::register($this);
?>

这篇关于Css和bootstrap在yii2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆