Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

How to sclae image

HI,

How can i scale image?

So what i mean if a picture is 100px width and 50px height, but i dont know it, and i want it to be smaller but so it keeps its properties , how do i do it?

1 Answer

There are numerous ways this could be answered, but it really is up to what you are trying to accomplish. You can simply specify an inline value using width="100px" or you can use CSS to control the size using a class.

.scale-me{
    width: 100%;
    max-width: 50px; /* or whatever the size should be */
}

I managed to do it.

My code

.logo img{
    width: 140px;
    height: auto;
}

But thank you, if that works.

Ok yeah, that's all you need to do. You can also make them scale doing the above solution I provided, that way if the viewport size is smaller, the image will scale down.

i preffer your way , thank you :D!