I am currently developing an employee directory that allows users to search for a specific employee and view their information in a tree or org-chart layout. To achieve this, I have implemented the Google Org Chart code for generating the chart. Each employee's contact card is displayed within a <td>
, with managers and subordinates arranged above or below in separate <tr>
elements.
https://i.sstatic.net/DZCed.png
While scrolling horizontally to view a small number of subordinates is not an issue, it becomes cumbersome when there are more than 10 employees as the searched employee may be out of sight:
https://i.sstatic.net/PKN9c.png
This situation can be frustrating for users. I attempted to solve this by placing an anchor (<a name="anchor">
) within the card and jumping to it on page load. However, this only partially scrolls the page, making it less effective.
My goal is to have the employee's card centered on the screen so that it grabs immediate attention from the user.
Is there a method to directly jump to the searched employee when the page loads?
If needed, here is a sample code snippet representing an individual card:
<td>
<h1>Mike</h1>
<div class="cardBody">
<img src="Images/stock1.jpg" style="float:left; margin-right:5px;" />
<table class="data" cellpadding="0">
<tr>
<td><i class="fa fa-briefcase"></i></td>
<td><span style="color:red;">President</span></td>
</tr>
<tr>
<td><i class="fa fa-building"></i></td>
<td>Administration</td>
</tr>
<tr>
<td><i class="fa fa-globe"></i></td>
<td>Home Office</td>
</tr>
<tr>
<td><i class="fa fa-phone"></i></td>
<td>Ext. 2402</td>
</tr>
<tr>
<td><i class="fa fa-envelope"></i></td>
<td><a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0e6b636f67624e6f6a6a7c6b7d7d206d6163">[email protected]</a>">Send Email</a></td>
</tr>
</table>
</div>
</td>