0

I change an image in the header based on which menu item is selected. The problem is that the image stretches in the image control. I want it to automatically zoom without distorting the image. Is this possible.

Note: The images reside in an images folder and are not all the same size.

Javascript

<script type="text/javascript">

    function ChangeProjectImage(imgpath) {
        var img1 = document.getElementById("Image2")
        img1.src = imgpath;
    }

</script>

2 Answers 2

2

I would recommend setting the CSS property 'width'. Use a width that suits your needs and your images. It will be implemented like this:

width:300px;

Since you don't want to distort your images, you should likely use the smallest width that your images have. All these images have different widths, but since the 'width' property is set to 80px, they all look like the same width, without distortion.

Sign up to request clarification or add additional context in comments.

1 Comment

Your solution worked out great! Thank you. I made sure not to set the height property because that was distorting it.
0

I don't think you can automatically zoom, except you know how much zoom are you looking for.

CSS

Zoom:200%;

1 Comment

so i would have to mathamatically figure out the image size then set the Zoom style accordingly?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.