Reputation: 7986
What is the best practice to limit the maximum image width on the browser, with only HTML and CSS? I did a search on Google.com, and I didn’t find any good results. Thanks!
Also, I want to keep the proportion height ratio as well.
Upvotes: 1
Views: 1742
Reputation: 13139
Use style="max-width:NNNpx"
(or max-height:NNNpx
) (you can use %
as a measurement as well - e.g. max-width:10%
)
Upvotes: 4
Reputation: 1395
You can limit the width of images using CSS:
img.limit-width {
max-width:50%;
}
You can use px
and em
in addition to a percentage as well.
Upvotes: 1