0

I want one container, containing a text with 50% on the left and on the right an image with 50%. But the image does not scale to 50% of the width. What's wrong here?

<div style="width:100%;">
<div style="widht:50%; float:left;background-color:#efefef;height:200px;width:50%;">
My Texting
</div>
<div style="width:50%; float:left;">
<img src="http://www.howtobeast.com/wp-content/uploads/2015/03/crossfit-fuengirola-slide03.jpg">
</div>

https://jsfiddle.net/kLcxnojn/

Marc Ster
  • 2,276
  • 6
  • 33
  • 63

3 Answers3

2

you need to give your image width 100%;

img{ width:100%; }

https://jsfiddle.net/kLcxnojn/

ohadsas
  • 479
  • 2
  • 7
  • 23
1

You've to define, that the image size should not extend over the maximum width of it's containing block. Just add this to your CSS.

img{
    max-width:100%;
    height: auto;
}

Fiddle

Ramiz Wachtler
  • 5,623
  • 2
  • 28
  • 33
1

From this answer:

<img src="the source" style="max-width:100%; max-height:100%;">

Demo: https://jsfiddle.net/kLcxnojn/1/

Community
  • 1
  • 1
Majid Fouladpour
  • 29,356
  • 21
  • 76
  • 127