How to adapt images in api calls?
P粉138871485
2023-09-05 13:36:09
<p>This is my first time posting anything here, so if I'm missing something, please let me know! Ok, so my problem is that the images in the category page don't fit with each other and no longer line up. This happened after I learned a little JavaScript and getting images from API calls. Now they don't look that good anymore...especially in mobile view. How can I make them the same size? BTW, I'm a complete noob.
Here is the link to my page: https://lovely-croissant-3cceca.netlify.app/</p>
<p>I tried fixing it with CSS, but it no longer "reacts" when I change something. Mobile view in category page, image too tall. However, when I try to lower them in the media query, the desktop version also changes. I know this is probably something I'm doing when I'm experimenting with javascript. I also can't change the name "test" to something else because everything will be disrupted...</p>
The important thing is the output, instead of calling the image via API, we can use CSS to handle the result.
The movie title pushes the images down because they are in the same container so we have to give them height.
The images have different proportions, so you can use
object-fit: cover
to crop the image at the maximum size with the minimum image height.On mobile: You need to set
overflow
tovisible
and remove thepadding
.container- too True (otherwise there would be multiple extra spaces) and only added to the parent.child
fromSomething like this would be done: