Can you calculate the CSS height of an image with a width of 3px?
The original image is:
- Height: 400px
- Width: 800px
I have attempted to:
Convert the 3px into a percentage based on the original image width:
function getPercentageOfWidth(v){
return 100 * v / originalImageWidth; // Original image width
}
function getHeightFromPercentage(v){
return v / 100 * originalImageHeight; // Original image height
}
var imgWidthPercentage = getPercentageOfWidth(3);
var imgHeightFromPercentage = getHeightFromPercentage(imgWidthPercentage);
// Unfortunately, the calculated height was incorrect
Any assistance would be greatly appreciated.