Spenk
Spenk

Reputation: 49

fit an picture in the entire div

how do i make a pictre fit in the entire div when i create a div with css the picture wont fit fully inside it. it will shrink instead. an image how it currently looks like http://img90.imageshack.us/img90/510/pictureframe.png

css part

#avatar{
padding:35px;
height:70px;
width:50px;
margin: 0px 0 0 0px;
background-color:red;
}

html part

<div id="avatar">
<img src="/Avatar.png" style="width: 100%;" style="height: 100%;" alt="">
</div>

Upvotes: 1

Views: 125

Answers (1)

Mr. Alien
Mr. Alien

Reputation: 157334

You are using 2 style attributes, so the latter 1 will take over the first 1, so it's only setting the height and not the width to 100%

<img src="/Avatar.png" style="width: 100%; height: 100%;" alt="">

And just noticed your CSS, you are using padding so that will make the red background visible around your image

Demo

Upvotes: 4

Related Questions