www.webdeveloper.com
Results 1 to 2 of 2

Thread: Change img height based on div height

  1. #1
    Join Date
    Aug 2012
    Posts
    4

    Question Change img height based on div height

    Hi everyone,

    I am trying to create a script that will change the height of an image to a set value depending on the height of a DIV. Basically, the DIV contains a collapsable table and the img is the page's background. I want the background to re-size based on how much of the table is visible. I hope this isn't too confusing.

    Here is my script:

    Code:
    	<script type="text/javascript">
    	function setbgsize() {
    	 var bgimg = document.getElementById('GB');
    	 var tbh = document.getElementById('FAQtable');
    	 if(tbh.style.height = '2816px') {
          bgimg.style.height = '1725px';
    	   }
    	 else if(tbh.style.height = '1131px') {
          bgimg.style.height = '1025px'; 
    		}
    	 else if(tbh.style.height = '803px') {
          bgimg.style.height = '825px'; 
    		}
    	 else if(tbh.style.height = '639px') {
          bgimg.style.height = '500px';
    		}
    	 else(tbh.style.height = '118px') {
          bgimg.style.height = '450px';   	  	  
    		}
    	}
    	</script>
    Cheers,
    Oli.

  2. #2
    Join Date
    Aug 2012
    Posts
    4
    Bump

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles