473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Positioning anchor/cell contents within a scrollable div

127 100+
Hi all,

This is a pretty simple question, but after some hunting on the web I can't find the answer:

I have a table embedded in a scrollable div, and have each cell anchored so that when a click on a button in another table, the div is scrolled to the corresponding cell of the first table. However, it is positioned such that the cell's contents start at the top-left of the window.

Can I add code which centers the contents of the cell/anchor in the middle of the window of the scrollable div?

Thanks!
Mar 3 '08 #1
5 1983
Could you post some of the code you currently have on your page? This will help me determine what changes to make.

Thanks.
Mar 4 '08 #2
phub11
127 100+
Thanks johnjohn! Below is what I think is all the salient code:

Expand|Select|Wrap|Line Numbers
  1. #holderdiv {
  2. width: 170px;
  3. height: 110px;
  4. overflow: scroll;
  5. border: 1px solid black;
  6. }
  7.  
  8. function go(loc) {
  9. i = parseInt(loc.substr(5));
  10. window.location.href = loc;
  11. }
  12.  
  13.  
  14.       <td><input name="pos" onclick="go('#cell1');"
  15.  type="radio"></td>
  16.  
  17. <div id="holderdiv"> 
  18. <table style="text-align: center; width: 1700px" id="table1"
  19.  border="1" cellpadding="0" cellspacing="0">
  20.   <tbody>
  21.     <tr>
  22.       <td style="width: 150px; height: 100px;"><div style="position: relative;" id="cell1">A1<br>
  23. Empty</td>
  24.       <td style="width: 150px; height: 100px;"><div style="position: relative;" id="cell2">A2<br>
  25. Empty</td>
  26. </div>
  27.  
Mar 4 '08 #3
phub11
127 100+
Hi again!

Just seeing if anyone has a suggestion.

Thanks!
Mar 5 '08 #4
rnd me
427 Expert 256MB
the cell's offsetTop and offsetLeft properties are what you need.
Mar 8 '08 #5
phub11
127 100+
Hi johnjohn+rndme,

Thanks for the reply.

I actually ended up using mootools to do it in JS. It adds a nice sliding effect too!
Mar 8 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dennis M. Marks | last post by:
I have a javascript that generates a monthly calendar. There are 2 <div>s. One called "calendar" is changed dynamically. The other is called "controls" and is fixed. They are both placed within a...
4
by: bengee | last post by:
Hi First off - by the word "anchor" i DON'T mean a link, i.e. <a></a> tags I'm trying to position a <select> box inside a <div>. I can use relative positioning to set where the box should...
7
by: glutinous | last post by:
I've looked at manuals and experimented until my brain's oozing out of my ears, and I still can't figure out what I anticipate will prove to be fairly basic css layout knowledge. I'd be amazed if...
20
by: Geoffrey H. Goldberg | last post by:
I have made a remote control window which opens from its parent. On loading, the remote is positioned relative to the screen using window.moveTo(x,y). What I would like to happen is the remote...
9
by: kojim | last post by:
Test page: http://www.key-horse.com/linkt.html I have a td that's styled to look something like a button, and on that button is anchor text. So far, I can't make the entire "surface" of the...
1
by: UJ | last post by:
How could I make a cell scroll. I have a cell that contains a datalist and I want to be able to have just the contents of the cell be scrollable; everything else for the table should remain...
2
by: nino9stars | last post by:
Hello, I have just started messing with absolute positioning on webpages, and it definitely let's you do some creative things. Well, after much searching and help, I got the images I was using...
1
by: chris f | last post by:
Some of the cells in my ASP.NET 2 table have a popup that appears when the user hovers the mouse over a text area that is indicated using an anchor tag. The popup is implemented as a DIV tag...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.