dev.e.loper
dev.e.loper

Reputation: 36044

How can I scale element height and width using CSS?

Is there a way using CSS to scale elements. For example, if I have an image, how can I say

img.height = image.height * 0.75  // scale down to 0.75

using CSS?

Upvotes: 6

Views: 9033

Answers (2)

enloz
enloz

Reputation: 5824

Try this:

div.zoomed { zoom: 0.75; -moz-transform: scale(0.75); }

Should work in: Firefox 3.5, IE 5.5+, Opera, Safari 4, Chrome

Edit: You should also add -webkit-transform: scale(0.75); for Chrome and Safari, although latest versions supports zoom

Upvotes: 8

MOleYArd
MOleYArd

Reputation: 1268

As of CSS 2.1 you cannot change dimensions of one element depending on other element (including itself) dimensions.

You will have to use JavaScript for this.

It probably will be possible in CSS3 with CSS variables.

Upvotes: -1

Related Questions