Background images path in Sass and Compass
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')
Have a variable in images path in Sass?
Have you tried the Interpolation syntax?
background: url(#{$get-path-to-assets}/site/background.jpg) repeat-x fixed 0 0;
Sass/Compass - Use variables for relative paths
I think you need to interpolate the variable:
$admin_img: '../../img/admin';
body {
background: url(#{$admin_img}/background.png);
}
Related Topics
How to Float an Element Left with Full Height of the Wrapper
How to Set CSS Only for Specific Ie Browsers
Pure CSS Solution - Square Elements
Twitter Bootstrap 3 How to Activate Navbar-Collapse on Small Devices
CSS Using Negative Relative Positioning Issue
Change Navbar Height in Bootstrap3
How to Vertically Center Align a Position:Relative Element
Set Dot Color of 'Text-Overflow: Ellipsis'
Change Text Color Black to White on Overlap of Bg
Firefox 30.0 - -Moz-Appearance: None Not Working
Cannot Understand the Use of :Host in Components in Angular2
Float: Right in IE7 Dropping to a New Line
Adding Custom CSS Tags to an Rmarkdown HTML Document
CSS Transform to Skew the Shape to a Trapezium
Which Browsers Support Page Break Manipulation Using CSS and the Page-Break-Inside Element
Override Jquery UI Datepicker Div Visible Strangely on First Page Load