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

HTML How to Make a Website Adding Pages to a Website Add Iconography

Derek Derek
Derek Derek
8,744 Points

Images of different size. How do I make them aligned?

Instead of using the provided images by Treehouse, I tried using my own images. However, because my images are of different size, they don't look good on the website. I tried assigning them hard values by assigning each of the image a class in the HTML file and using .class-name in the CSS file, but if I resize the brower, the images do not resize themselves.. For example, I want to put a 1008 x 1008 image and a 1365 x 1024 image on the same row, aligned. Thank you in advance!!

Max Kutner
Max Kutner
7,595 Points

Ok.

Since you set them to a common class, you could add a new rule declaring a margin value that would equalize them at least.

Try that first.

Max

Sergey Podgornyy
Sergey Podgornyy
20,660 Points

Can you provide your code? Are you saying about horizontal alignment, or vertical alignment, because they have different height?

1 Answer

In order to do this, you have few options. The easiest is the following:

Align them via height. Create a class for the images, say .grid-image and give this class the following attributes:

.grid-image {
  height: 300px; // Give a common height
  margin: 10px; // This will space them out equally
  float: left; 
}

This should result in a basic row based alignment of images.

Here is an example of this here: http://port-80-ayjfhx3nrf.treehouse-app.com/