Background images path in Sass and Compass

前端 未结 1 763
你的背包
你的背包 2020-12-14 10:20

This is mentioned in config.rb file

images_dir = \"images\"

I use 2 folder for images in my projects inside images folder

i         


        
相关标签:
1条回答
  • 2020-12-14 10:33

    You should use the image-url URL helper. It "generates a path to an asset found relative to the project's images directory" which you defined in your config.rb. You can also set the third parameter $cache-buster to false to remove the generated ?1327592426

    Sass:

    // image-url arguments:
    // $path: path relative to images directory in config.rb
    // $path-only: if true, will cause only the path to be returned instead of a `url()` function
    // $cache-buster: When set to `false` no cache buster will be used (i.e. `?313420982`)
    $header-img: image-url('background/sass.gif', false, false)
    background-image: $header-img
    

    Generated CSS:

    background-image: url('images/background/sass.gif')
    
    0 讨论(0)
提交回复
热议问题