...text...images...
...

Resize the HTML element

I have HTML code similar to

<div id="resizeThis">
<div style="background: url(...)">...text...images...</div>
...
</div>

I want to resize a div with all its contents to an arbitrary size. For example, I could use JavaScript to get the width of the div and then resize all the elements accordingly, but what is the easiest way to do this? I can use jQuery, I tried:

$("#resizeThis > *").css('width', '64px').css('height', '64px');

but he only reduced #resizeThis, not its children.

And what can I do for background, text, etc.

I want to do this to create thumbnails (usually 25% of the original size).

+3
source share
3 answers

I found the perfect solution!

I just do:

$('#resizeThis').css('-webkit-transform', 'scale(0.5)');

and it correctly changes all the elements under it! :)

Gecko. .

+1

$("#resizeThis *").css('width', '64px').css('height', '64px');

> .

#resizeThis, div. :

$("#resizeThis").find("*").andSelf().css('width', '64px').css('height', '64px');

CSS .css().

.

$("#resizeThis *").find("*").andSelf().addClass("MyCssClass");
+2

(, p span). (display: block). , , .

, - . , . , .

0

Source: https://habr.com/ru/post/1729228/


All Articles