1

Imagine websites like 9Gag. You upload an image and they display it always with the same width and only the height changes.

How can I achive this? I cant even resize my images hardcoded.

CSS:

.post img{
height: 200px;
width: 300px; 
}

HTML:

<div class="post">
  <img src="img/bf1.jpg">
</div>

The image stays the same size.

2 Answers 2

2

You should change CSS style to:

.post img{
  height: auto;
  width: 300px; 
}
Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried:

<div class="post">
  <img height="200px" width="300px" src="img/bf1.jpg">
</div>

Hope this helps!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.