Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Image width using inline css

Tags:

html

css

I want to set the width of Image. here is my code :-

<div style="width: 630px;">
        <img src="Image/welcomeimage.jpg" alt="no image" />
  </div>

Here is my situation, I don't have to set the width of Image. Only I can set the width of Div. So I have to set the image width using div. How can I do this?

[Edit] Thanks to all for helping me. Now I solved my problem. Initially, I was told not to use CSS, I had to solved this issue using Inline CSS. But It was not possible. So I decided to use CSS.

like image 434
Rajesh Biswas Avatar asked Dec 26 '22 05:12

Rajesh Biswas


1 Answers

Use max-width

You can use the max-width property which is supported in all modern browsers and IE 8 and above.

To use it call it in your css like so:

div img { max-width: 100%; }

This will stretch your image to the div's width.

like image 155
hitautodestruct Avatar answered Dec 28 '22 19:12

hitautodestruct