Jump to content

Jquery - Scaling A Div


Drongo_III

Recommended Posts

Hi Guys

 

I am making a simple lightbox style popup div. What I want is for the div to popup (containing an image) and then scale to 100%. But I want it to scale so it essentially looks like the parent div is opening from the center out. I've seen this effect on lightboxes in the past.

 

The problem I have is that the div appears to only scale from the top left - which you can see because the container's image in the example below shows from the top left. I've tried to play about the various parameters you can set but none seem to achieve what i want.

 

So...

 

a.) Is it possible at all?

b.) Is there just some css trickery I am not taking into account?

 

Thanks, Drongo.

 

Simplified example follows:

 

<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>


<style type="text/css">
div {
margin: 0px;
width: 275px;
height: 100px;
background: green;
border: 1px solid black;
position: absolute;
left: 200px;
top: 200px;
overflow: hidden;
padding: 20px;
display: inline-block;
display: none;

</style>
<script>
$(document).ready(function() {

$("#clicks").click(function () {
 $('div').show("scale", {direction: 'both', scale: 'both'}, 1000);
//alert(1);
});
});
</script>
</head>
<body >
<a href="#" id="clicks">Show Div</a>
<div>
<img src="http://www.google.co.uk/images/srpr/logo3w.png" />

</div>
</body>
</html>

Edited by Drongo_III
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.