s1yman Posted August 26, 2008 Share Posted August 26, 2008 Hi All, I was wondering if it is possible to make an image scale to the percentage of the page (as opposed to the % of original size.) Or to make it scale with the size of the div? All & any help is appreciated. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
manoilayans Posted August 26, 2008 Share Posted August 26, 2008 hai s1yman, <div id="div_id" style="height:300px; width:300px;"> <img id="img_id" src="PPX_T2.gif"> </div> <script type="text/javascript"> document.getElementById('img_id').style.height = document.getElementById('div_id').style.height; document.getElementById('img_id').style.width = document.getElementById('div_id').style.width; </script> Regards, manoilayans Quote Link to comment Share on other sites More sharing options...
s1yman Posted August 26, 2008 Author Share Posted August 26, 2008 Hi Manoilayans, Thanks for the quick response. Is it possible to incorporate that to my css file? One example div is as follows; .div0 { width:50%; float:left; text-align:center; position:relative; border-style:solid; border:solid 1px #0066FF; margin:1px; overflow:hidden; } Thanks for the help. Quote Link to comment Share on other sites More sharing options...
bronzemonkey Posted August 26, 2008 Share Posted August 26, 2008 .mydiv img {width:80%;} Quote Link to comment Share on other sites More sharing options...
haku Posted August 26, 2008 Share Posted August 26, 2008 You probably could have tried it out in less time than this thread has taken! Just give it a percentage width, as bronzemonkey said. It will look strange at large resolutions though. Quote Link to comment Share on other sites More sharing options...
Derleek Posted August 27, 2008 Share Posted August 27, 2008 I would imagine you could limit the size of the image w/ a script? Quote Link to comment Share on other sites More sharing options...
s1yman Posted August 31, 2008 Author Share Posted August 31, 2008 But as I said, I want it to be a percent on the div, not of its original size. ??? Quote Link to comment Share on other sites More sharing options...
bronzemonkey Posted August 31, 2008 Share Posted August 31, 2008 But as I said, I want it to be a percent on the div, not of its original size. ??? Did you even try out that simple bit of code? I think not, because then you wouldn't be asking (again) for something that has already been solved for you. Quote Link to comment Share on other sites More sharing options...
s1yman Posted September 2, 2008 Author Share Posted September 2, 2008 Yes I obviously did, or I wouldn't be asking (again) for something that has already been solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.