How To Resize An Image In Percentage? Html Image Size Percentage

I was wondering if in the width and height
*

QcomQcom
17.1k2929 gold badges8484 silver badges112112 bronze badges
địa chỉ cửa hàng a comment |

8 Answers 8


Sorted by: Reset to mặc định
Highest score (default) Date modified (newest first) Date created (oldest first)
85
Note: it is invalid lớn provide percentages directly as
*

PatPat
24.6k66 gold badges7171 silver badges6767 bronze badges
2
địa chỉ a comment |
29
You can phối one or the other (just not both) & that should get the result you want.

Bạn đang xem: How to resize an image in percentage? html image size percentage


nội dung
Follow
answered Aug 3, 2010 at 12:38

*

FoscoFosco
37.3k66 gold badges8383 silver badges100100 bronze badges
2
add a bình luận |
9
Here is the difference:

This sets the image to half of its original size.

This sets the image khổng lồ half of its available presentation area.

For example, if you put this as the only element on the page, it would attempt lớn take up 1/2 of the width of the page, thus making it potentially larger than its original form size - not half of its original form size as you are expecting.

If it is being presented at larger than original size, the image will appear greatly pixelated.


tóm tắt
Follow
answered Aug 3, 2010 at 12:46
*

FentonFenton
223k6565 gold badges372372 silver badges383383 bronze badges
địa chỉ a comment |
7
Try use scale property in css3:

75% of original:

-moz-transform:scale(0.75);-webkit-transform:scale(0.75);transform:scale(0.75);50% of original:

-moz-transform:scale(0.5);-webkit-transform:scale(0.5);transform:scale(0.5);
nói qua
Follow
answered Dec 27, năm ngoái at 8:27
Nalan MadheswaranNalan Madheswaran
9,12011 gold badge5151 silver badges3939 bronze badges
địa chỉ a phản hồi |
2
width="50%" & height="50%" sets the width & height attributes lớn half of the parent element"s width & height if I"m not mistaken. Also setting just width or height should set the width or height lớn the percentage of the parent element, if you"re using percents.

Xem thêm: Dystopia Là Gì - :: Suy Ngẫm & Tự Vấn :: Chúngta


giới thiệu
Follow
answered Aug 3, 2010 at 12:39
pkaukopkauko
49266 silver badges1212 bronze badges
4
địa chỉ cửa hàng a comment |
2
Given the lack of information regarding the original image size, specifying percentages for the width và height would result in highly erratic results. If you are trying khổng lồ ensure that an image will fit within a specific location on your page then you"ll need to use some server side code khổng lồ manage that rescaling.


tóm tắt
Follow
answered Aug 3, 2010 at 12:40
LazarusLazarus
40.1k44 gold badges4242 silver badges5454 bronze badges
0
địa chỉ cửa hàng a comment |
1
From W3Schools

The height in percent of the containing element (like "20%").

So I think they mean the element where the div is in?


share
Follow
edited Feb 25, năm trước at 19:06
piro
12.5k55 gold badges3333 silver badges3535 bronze badges
answered Aug 3, 2010 at 12:39
JavaPeteJavaPete
4311 silver badge66 bronze badges
showroom a phản hồi |
-5
There is actually a way to bởi vì this with html only. Just sets:


tóm tắt
Follow
answered Jun 1, năm ngoái at 2:32
GilgameshGilgamesh
1
showroom a bình luận |

Your Answer


Thanks for contributing an answer to lớn Stack Overflow!

Please be sure khổng lồ answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding khổng lồ other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.


Draft saved
Draft discarded

Sign up or log in


Sign up using Google
Sign up using Facebook
Sign up using email and Password
Submit

Post as a guest


Name
thư điện tử Required, but never shown


Post as a guest


Name
thư điện tử

Required, but never shown


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy và cookie policy


Not the answer you're looking for? Browse other questions tagged html image image-size or ask your own question.


The Overflow Blog
Featured on Meta
Linked
14
What are the consequences of using percentage for width,height attributes of an img element?
Related
1069
How bởi vì I retrieve an HTML element's actual width & height?
382
Adjust width và height of iframe to lớn fit with content in it
654
How to force child div to lớn be 100% of parent div's height without specifying parent's height?
298
Does height và width not apply to span?
368
Should I kích thước a textarea with CSS width / height or HTML cols / rows attributes?
279
How to get the width và height of an android.widget.ImageView?
177
kiểm tra image width & height before upload with Javascript
0
Bootstrap 3 | Responsive col width & height
1
CSS width/height having different effect than HTML width/height attributes, depending on element type
3
How lớn get a div with extrinsic height and intrinsic width inside a flexbox
Hot Network Questions more hot questions

Question feed
Subscribe lớn RSS
Question feed khổng lồ subscribe to this RSS feed, copy & paste this URL into your RSS reader.


lang-html
Stack Overflow
Products
Company
Stack Exchange Network
Site kiến thiết / biểu tượng logo © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. Rev2022.5.3.42026


Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device & disclose information in accordance with our Cookie Policy.