Ways to conceal rows and columns of a table at the edges

Suppose you have a table measuring 82x82, but you only want to display the central 80x80 section of the table while still retaining the data in the hidden cells. One solution could be enclosing the table within a div element that hides the unnecessary parts of the table. This can be achieved as follows:

#workspace {
  position: absolute;
  width: 800px;
  height: 800px;
  top: 50%;
  left: 50%;
  margin-left: -400px;
  margin-top: -400px;
  overflow: hidden;
}

table {
  position: absolute;
  margin-left: -10px;
  margin-top: -10px;
  width: 820px;
  height: 820px;
}
<div id="workspace">
  <table>

  </table>
</div>

Upon inspecting the console in Mozilla, you might notice a glimpse of the hidden cells at the bottom of the table. You can view this issue here: https://i.sstatic.net/9jMlY.png

Hence, the query arises as to how one can rectify this problem or suggest alternative methods to conceal the superfluous sections of the table.

P.S. The table cells are dynamically generated using JavaScript.

Answer №1

Employ the nth-child() selector in order to target and conceal the table elements located at the edges.

 tr:first-child,
 tr:last-child,
 td:first-child,
 td:last-child {
   display: none
 }

Answer №2

Here is an example of the code you may be looking for:

#workspace {
  width: 800px;
  height: 800px;
  top: 50%;
  left: 50%;
  position: relative;
  overflow-y: hidden;
}
#workspace > table {
  position: absolute;
  width: 820px;
  height: 820px;
  top: -20px;
  left:-20px;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with host-context scss rules not appearing in final production version

I am facing an issue in my Angular project where the scss rules that define how components should look when within the context of another component are not being applied when I build for production and put it live. Here is an example: :host-context(my-tabl ...

tips for moving a button 2 pixels up or down in position

How can I adjust the position of my button by a specific number of pixels up or down from where it currently is? Can you provide guidance on how to find the current location? Thank you in advance. ...

Use ng-class in a P tag to assess a variety of expressions

Is there a way to apply ng-class to automatically evaluate negative values within a < p > tag? <p <strong>LW$:</strong> {{d.lw_metric}} <strong>LW:</strong> {{d.lw_metric_percentage}} <strong>L4W:</strong> {{ ...

Develop a Modal Form using Bootstrap (HTML)

I followed a tutorial on creating a modal form with Bootstrap, you can find it here: http://www.youtube.com/watch?v=HCEbp07hfLw I replicated the steps shown in the video, but when I try to open the page in my browser, nothing appears. I have added the Bo ...

Is there a way to prevent hover effects on the outer div when hovering over the inner div?

I am facing an issue with disabling hover effects on an outer div when hovering over an inner button. I have tried various methods but haven't been successful in achieving the desired outcome. .container { background-color: #e6e6e6; width: 400p ...

Populate a table cell with a div element in HTML

How can I make a div inside a rowspanned table cell 100% high of the cell? Check out this example for reference: https://jsfiddle.net/gborgonovo/zqohw286/2/ In the provided example, I want the red div to vertically fill the yellow cell. Any suggestions on ...

What is the best way to eliminate the scroll buttons from a scroll bar within a scrollPane in JavaFX?

Here's a snippet of code from the CSS file: .scroll-bar .button { visibility: hidden; -fx-background-color: black; } Despite this code, the scroll bar buttons are unaffected. You can see an image of the issue here. I would greatly appreciate any hin ...

Creating a two-column post loop in Wordpress is a great way to display content in a

I've been attempting to separate posts for a long time without success. No matter what variations I try, the result is always either a single post or duplicating all of them. In other words, multiple posts are not displaying as intended. If anyone ha ...

Having trouble obtaining the video link from a tweet on Twitter using Selenium

Struggling to extract video clip download/streaming URLs from Twitter using Selenium in Python. Can't seem to find the direct source URL on the page. Check out this tweet for reference: https://twitter.com/Tesla/status/1711184330792579093 Is there a ...

IE causes link_to :remote => :true to malfunction

I'm facing an issue with remote links in Internet Explorer, and it's crucial to resolve it promptly as the deadline is today. The problem arises when we utilize AJAX to initiate a remote call to an action and evaluate the JavaScript returned. Wh ...

Styling Material UI components with CSS is a great way to

I'm facing difficulties while working with Material UI components. Currently, I have a Material UI table and I want to center-align the text within it. The standard CSS of Material UI contains an element named MuiTableCell-root-60 which has a text-a ...

What is the best way to incorporate (+/-) buttons to increase or decrease numbers in this code snippet?

Hey everyone, I hope you're all doing well! I need some assistance in transforming this quantity picker from a dropdown to have buttons like the one shown here with plus and minus symbols: https://i.stack.imgur.com/O0uUa.png I would like to impleme ...

Place an image on top of adsense

Is there a way to overlay an image on top of Google AdSense ads in order to track user clicks? I am trying to implement an onclick method for when someone clicks on the ads. .ad-alert { width: 728px; height: 400px; background: #cccccc; mar ...

Is there a way to showcase several items simultaneously on a bootstrap 5 carousel slide?

I currently have a bootstrap 5 carousel with controls that I want to modify. My goal is to create a slideshow where each slide displays 2 items, and I can scroll through one image at a time. Starting from here: https://i.sstatic.net/ROgoL.png And ending h ...

Jekyll adjusting the starting line of code snippet formatting

Currently, I'm in the process of setting up code highlighting for my blog using Jekyll and Pygments. However, I'm facing an issue where the first line of every code snippet seems to be slightly offset. To create a gutter effect, I'm utilizin ...

Set up bootstrap 5 on your website while incorporating the beloved color scheme of bootstrap

Bootstrap has introduced new color schemes in version 5 compared to version 4. Is it possible to update to Bootstrap 5 while retaining the original color palette of Bootstrap 4 without the need for manual file adjustments? Are there any content delivery ...

Choose a particular text node from the element that has been selected

Can anyone provide guidance on how to extract the text "Items Description" from the following HTML snippet using jQuery? <div class="items"> "Items Description" <ul> <li>1. One</li> <li>2. Two</li&g ...

Sending a file through an Ajax POST request to a PHP server

I am attempting to upload the HTML input file to my PHP file using a different method than the traditional synchronous HTML forms. The problem I am encountering is that it seems like I am not correctly POST'ing the input file to my PHP file because t ...

Implement Offcanvas feature with Bootstrap 3 Navbar set to Fixed Top position

I am in the process of creating a website that will feature a large menu. However, I am not a fan of the collapsed menu that comes with BS3. Instead, I would like to implement a drawer or off-canvas menu similar to the one showcased in BS3's offcanvas ...

Ensure that the buttons are arranged in a single row and have horizontal overflow in the mobile version

After using Bootstrap, I managed to create a row with multiple buttons. I encountered an issue where the buttons do not align properly when viewed on mobile devices, as depicted in the image provided. Is there a solution to ensure that these buttons alwa ...