【问题标题】:Installing Bootstrap theme in Symfony 2 project在 Symfony 2 项目中安装 Bootstrap 主题
【发布时间】:2014-05-28 18:11:11
【问题描述】:

我正在考虑在我的 SF2 项目中安装 this theme,我注意到页面顶部有 4 个文件可供下载,即:

  • bootstrap.min.css
  • bootstrap.css
  • variables.less
  • bootswatch.less

我已经成功安装了 less.php (oyejorge/less.php) 解析器以及引导程序本身,并且我有 Assetic 设置将我的所有 CSS 压缩在一起并将其输出到页面:

<link href="/app_dev.php/css/425e28c.css" type="text/css" rel="stylesheet">

但是,我想在上面的链接中安装 Superhero 主题,但我找不到任何有关如何执行此操作的教程?是否只是覆盖variables.less并导入bootswatch.less的情况?

【问题讨论】:

  • Bootswatch 主题会覆盖引导 css,因此最终您不会加载这两个文件 - 仅加载主题文件。
  • 我花了很多时间寻找明显的 JS 错误,只是为了发现我已经包含了两次 BS(原始 + 主题)...
  • @skrilled 所以我假设我需要在我的 composer.json 中保留twitter/bootstrap,但是我在哪里用 Bootswatch 主题替换引导 css。那真的是我的问题......我以前使用过引导程序,但我有点像 SF2 菜鸟。谢谢。
  • @jperovic 感谢您的提示,我一定不会同时包含两者。你知道我把主题提供的bootswatch.less 文件放在哪里了吗?

标签: php html css twitter-bootstrap symfony


【解决方案1】:

另请阅读https://github.com/thomaspark/bootswatch 上文档的“使用”和“自定义”部分。

如果您想按原样使用主题(无需自定义),您只需在 HTML 中包含 bootstrap.min.css 或 bootstrap.css:

<link href="/bootstrap.min.css" type="text/css" rel="stylesheet">

您也可以编译自己的主题版本:

  1. http://getbootstrap.com/getting-started/#download下载Bootstrap的源文件
  2. 在源文件中,将 less/variables.less 文件替换为从 bootswatch 下载的文件
  3. 将 bootswatch.less 复制到引导源文件的 less 目录中
  4. 然后,打开less/bootstrap.less 并在此文件末尾添加以下代码行:@import "bootswatch"
  5. 编译修改后的引导程序,如下所述:Error while executing assetic dump (parse error: failed at `&:extend(.clearfix all);`)

还要注意,Bootstrap 将供应商前缀的自动前缀添加到其构建过程中。自 v3.2.0 起,less/mixins/vendor-prefixes.less 中的供应商前缀 mixins 已弃用。所以你也应该在你的资产配置中添加https://packagist.org/packages/bit3/assetic-autoprefixer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 2014-07-31
    • 2015-11-21
    • 2020-08-16
    • 1970-01-01
    • 2016-02-17
    • 1970-01-01
    相关资源
    最近更新 更多