I have an image uploading website... have a look at this PAGE... I want to place this picture in such a way that it appears inside a border,, I tried using width and height attribute in img tag but by doing so the images whose dimensions are small are expanded to fit the table... Is there any way that i can get the dimensions (width and height) of a image and according to it manipulate the width and height of image in table... Hope you get what I am trying to say???
put a div around image and give width and height to that div. then place image with margin: auto. and don't use image tag rather use style attribute and set image as background to center it vertically as well
it should be something like this.. html and css both are provided.. <div class="image_preview" style="background-image:url(res/img/thumb_2.jpg);"></div> .image_preview { float: left; width: 200px; height: 200px; margin: 0px 0px 10px 10px; border: 1px solid #000000; background-repeat: no-repeat; background-position: center; } HTML:
I don't use DIV tag so I have no idea how to use it... i just want to ask that there;s something like ABSOLUTE and RELATIVE in div... can you please tell me what are these to things??? Again if I use this DIV tag then wont it will be placed at different positions on browser on resizing the browser???
you need to resize it.. like you calculate the width and height of that image.. //getting dimintions of picture $image = "blabla.jpg"; list($imgwidth, $imgheight) = @getimagesize("$image"); //now resize pic if($imgheight>550) { $height=500; echo "<img src=$image height=$height border=1>"; } else echo "<img src=$image border=1>"; PHP: