Jump to content

Dynamic Div Resize with Javascript


Guest Caderial

Recommended Posts

Guest Caderial

I am attempting to use javascrip to resize a div for lower resolution users , my issue is if I shrink the window it effectivly changes the size of the div to 1000px as expected but if i bring the browser window back out to my full size it stays at the 1000px.

 

Ideally i would like the div to scale down to 1000px instead of just jumping to 1000 px and when you widen your window again it would scale back up to 1300px;. any suggestions?

 

<script language="javascript">
          function fittheDivs(){
                if(document.body.clientWidth<1024){
                      document.getElementById('bodyimgwrapper').style.width="1300px";
                 }else{
                       //alert(document.getElementById('bodyimgwrapper').style.width);
                       document.getElementById('bodyimgwrapper').style.width="1000px";
                 }
           }
</script>
</head>
<body onresize="fittheDivs();">

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...