Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 04, 2011 09:37 AM by asteranup
Member
127 Points
238 Posts
Nov 04, 2011 07:57 AM|LINK
Hope all of you will be doing great.
I need to set the position of a div (or table) with respect to right offset.
I have a column and a table. The table is set to absolute. I need to set the position of table with respect to right offset of the column.
I am not able to get right offset, just like we can get elem.offset().left.
How can we set position of an element with respect to right,
All-Star
30184 Points
4906 Posts
Nov 04, 2011 09:37 AM|LINK
Hi,
What do you mean by offset right? I think you are talking about offset left +width. Check this-
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { setRight(); }); function setRight() { $("#div2").css({ "left": $("#div1").offset().left + $("#div1").width(), "top": $("#div1").offset().top + 20 }); } </script> </head> <body> <div id="div1" style="margin-top:100px; height:100px; width:600px;background-color:gray"> </div> <div id="div2" style="position:absolute; height:100px; width:200px;background-color:Yellow"></div> </body> </html>
azharrahi
Member
127 Points
238 Posts
Set position of a div or table with respect to right offset
Nov 04, 2011 07:57 AM|LINK
Hope all of you will be doing great.
I need to set the position of a div (or table) with respect to right offset.
I have a column and a table. The table is set to absolute. I need to set the position of table with respect to right offset of the column.
I am not able to get right offset, just like we can get elem.offset().left.
How can we set position of an element with respect to right,
asteranup
All-Star
30184 Points
4906 Posts
Re: Set position of a div or table with respect to right offset
Nov 04, 2011 09:37 AM|LINK
Hi,
What do you mean by offset right? I think you are talking about offset left +width. Check this-
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { setRight(); }); function setRight() { $("#div2").css({ "left": $("#div1").offset().left + $("#div1").width(), "top": $("#div1").offset().top + 20 }); } </script> </head> <body> <div id="div1" style="margin-top:100px; height:100px; width:600px;background-color:gray"> </div> <div id="div2" style="position:absolute; height:100px; width:200px;background-color:Yellow"></div> </body> </html>Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog