Change Image Size Via Parent Div
Solution 1:
I'm not sure about what you mean by "I have no access to image" But if you have access to parent div you can do the following:
Firs give id or class to your div:
<div class="parent">
<imgsrc="http://someimage.jpg"></div>
Than add this to your css:
.parent {
width: 42px; /* I took the width from your post and placed it in css */height: 42px;
}
/* This will style any <img> element in .parent div */.parentimg {
height: 100%;
width: 100%;
}
Solution 2:
Apply 100%
width and height to your image:
<divstyle="height:42px;width:42px"><imgsrc="http://someimage.jpg"style="width:100%; height:100%"></div>
This way it will same size of its parent.
Solution 3:
Actually using 100% will not make the image bigger if the image is smaller than the div size you specified. You need to set one of the dimensions, height or width in order to have all images fill the space. In my experience it's better to have the height set so each row is the same size, then all items wrap to next line properly. This will produce an output similar to fotolia.com (stock image website)
with css:
parent {
width: 42px; /* I took the width from your post and placed it in css */height: 42px;
}
/* This will style any <img> element in .parent div */.parentimg {
height: 42px;
}
without:
<divstyle="height:42px;width:42px"><imgstyle="height:42px"src="http://someimage.jpg"></div>
Solution 4:
I am doing this way:
<div class="card-logo">
<imgheight="100%"width="100%"src="http://someimage.jpg"></div>
and CSS:
.card-logo {
width: 20%;
}
I prefer this way, as if I need to upscale - I can use 150% as well
Solution 5:
Yours:
<divstyle="height:42px;width:42px"><imgsrc="http://someimage.jpg">
Is it okay to use this code?
<div class= "box">
<imgsrc= "http://someimage.jpg"class= "img"></div><styletype="text/css">.box{width: 42; height: 42;}
.img{width: 20; height:20;}
</style>
Just trying, though late. :3 For someone else reading this, letme know if the way i wrote the code were not good. im new in this kind of language. and i still want to learn more.
Post a Comment for "Change Image Size Via Parent Div"