php - Yii2 - wrong order of loaded CSS - extension's CSS breaks the layout
问题描述
Yii2 (v2.014), hail812/yii2-adminlte3, kartik-v/DatePicker.
Any page with a rendered datepicker breaks the theme. The font is smaller as expected, some other issues are noticable. I have found out, that the datepicker add additional css files in the html header. But instead of placing these lines AFTER the theme, they popup before all other "<link rel=stylesheet" lines. This is probably the reason for the broken layout. Is there any way to controll which order are the CSS files from plugins/extensions loaded?
解决方案
Yii的做法是使用AssetManager
AssetManager
允许您在php
类和应用程序配置中配置捆绑包。如果您使用的是基本模板,那就是config/web
.
您可以将扩展资产包配置为依赖于您想要包含在它们之前的那些,例如:
'components' => [
'assetManager' => [
'bundles' => [
'kartik\date\DatePickerAsset' => [
'depends' => [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset'
],
],
],
],
上面的代码块kartik\date\DatePickerAsset
只是一个示例,您需要找到您要配置的其他资产的名称并添加它们。
推荐阅读
- reactjs - nextjs 中的环境变量
- github - 如何使用 GITHUB_TOKEN 的代币替代品进行 Github 操作?
- reactjs - SVG sprite 图像未使用 React 在 iOS 和 Safari 上显示
- javascript - Javascript - .catch 异步回调
- python - Ax.dev 对搜索空间限制不做任何事情?
- html - css的边框属性在addClass()jquery中不起作用
- database - Tableau - 将完整的案例列表带入视图
- json - Azure 数据工厂使用动态列展平 json
- javascript - SyntaxError:在节点 js 中导入时出现意外的标识符
- javascript - Google Apps 脚本 - 如何有效地遍历驱动器树以到达特定文件夹