I am using the inline-image
function to create icon classes. This is my current SCSS:
.folder {
background: inline-image("icons/home/folder.png", 'image/png') no-repeat center;
height: 30px;
width: 41px;
}
I am looking for a function that can determine the width and height of the image so I can do something like this:
.folder {
background: inline-image("icons/home/folder.png", 'image/png') no-repeat center;
height: image-height("icons/home/folder.png", 'image/png');
width: image-width("icons/home/folder.png", 'image/png');
}
Does anything like this exist?
One of the simplest ways to resize an image in the HTML is using the height and width attributes on the img tag. These values specify the height and width of the image element. The values are set in px i.e. CSS pixels.
Found this http://compass-style.org/reference/compass/helpers/image-dimensions/
You've guessed the right function names.
To use them you'll need to install compass.
It will be something like this:
@import "compass/helpers";
.folder {
background: inline-image("icons/home/folder.png", 'image/png') no-repeat center;
height: image-height("icons/home/folder.png");
width: image-width("icons/home/folder.png");
}
By the way I would recommend you to use sprites for icons: http://compass-style.org/reference/compass/helpers/sprites/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With