5

I have a Rails app where I’m using the bootstrap-sass gem which lists autoprefixer-rails as a dependency.

I don’t quite understand how to get Autoprefixer to prefix my app’s CSS. Do I need some asset config? Will it prefix compiled Sass in dev while in asset debug mode?

According to autoprefixer-rails’s docs, I just have to clear my cache and write CSS... None of my compiled Sass has any prefixes, but Bootstrap’s CSS does.

Any help/explanations would be appreciated.

4

1 回答 1

8

发现很简单将 autoprefixer-rails gem 添加到你的Gemfile

# In gemfile
gem 'bootstrap-sass'
gem 'autoprefixer-rails'

# Install the gem
$ bundle install

清除缓存:

# Its very important
$ rake tmp:clear

尽管 gemautoprefixer-rails是对它的依赖,bootstrap-rails但它看起来像是在autoprefixer-rails内部使用并且sprockets对此一无所知。

.css在、.scss.sass文件中添加不带浏览器前缀的 CSS 样式。然后你发现你的样式添加了前缀。如果你有

.fullscreen a {
    display: flex;
}

你会得到

.fullscreen a {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
}
于 2015-08-29T08:20:31.893 回答