How to edit variable and compile .less with Bootstrap in Yii Framework?

…衆ロ難τιáo~ 提交于 2019-12-10 16:48:14

问题


I am using the php Framework Yii and I want to use it in combination with the Twitter Bootstrap Framework.

I did exactly the same steps like here: http://www.cniska.net/yii-bootstrap/setup.html for setting it up.

How can I change the default values for all the colors and so on? I changed it in the "variables.less" and it compiled successful even the bootstrap.less and the style.less, but nothing changed.

Sorry that I am such a newbie but could you tell which file I have to change and compile for changing the design?


回答1:


Assuming your less files are compiling properly, the colors should be changing in the compiled CSS files. At which point, you need to make sure your HTML files link to the newly compiled CSS file.




回答2:


As of Yii-Bootstrap ver 1.2.0, the css files are taken from path/to/bootstrap-extension/assets/css/ folder, therefore any changes you make to the base .less files should be compiled and stored in that folder. Check this line in the source:

Yii::app()->clientScript->registerCssFile($this->getAssetsUrl().'/css/bootstrap.css');

For example:

  • Css folder for extension is: project-name/protected/extensions/bootstrap/assets/css/
  • Base .less files in project-name/protected/extensions/bootstrap/lib/bootstrap/less/
  • Make a change in project-name/protected/extensions/bootstrap/lib/bootstrap/less/variables.less :

    @white:                 #ffe;// changed from #fff
    
  • Make a backup of original bootstrap.css just in case.

  • Compile protected/extensions/bootstrap/lib/bootstrap/less/bootstrap.less file.
    Example (server-side command-line compiling & while in project-name folder):

    $lessc protected/extensions/bootstrap/lib/bootstrap/less/bootstrap.less > protected/extensions/bootstrap/assets/css/bootstrap.css
    
  • Clear cache in browser, refresh to see change.




回答3:


I got to know that it is a good idea to copy the bootstrap's less files into a less folder in the root directory and to edit and compile them there. In this way it would be easy to update the bootstrap framework.

In this less folder I have a style.less file which imports the bootstrap.less of the extentions/bootstrap/ folder and my single edited files. There I have to pay attention when I use variables of other files then I need to import some less files that the variables are defined.



来源:https://stackoverflow.com/questions/10725349/how-to-edit-variable-and-compile-less-with-bootstrap-in-yii-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!