Layering digital sheets of paper and rearranging them with the help of CSS

I want to create a visual representation of a stack of paper sheets as a metaphor. The idea is to neatly stack the sheets on top of each other, with only the header of each sheet visible and the rest of the content covered.

!--------------
| Sheet 1
+--------------
| Sheet 2
+--------------
| Sheet 3
|
|
|

Additionally, I would like the ability to 'activate' a specific sheet, causing all other sheets to move down and reveal the content of the active sheet.

Here's an example:

!--------------
| Sheet 1
+--------------
| Sheet 2
|
| Sheet 2 content
| goes here
| this sheet is 
| 'active'
|
+--------------
| Sheet 3
|
|
|

To achieve this, I have tried using DIV containers with negative top margins, but this method only works for fixed height sheets. I have also created an .active class to attach to the active sheet's DIV in order to reveal its content.

This is the CSS I have used:


    .sheet {
      position: relative;
      width: 650px;
      height: 550px;    
      margin: -465px auto 0 auto;
    }


    .sheet .active + .sheet {
      margin: 0 auto 0 auto;
    }

However, this solution is limited to fixed heights. I am looking for a way to make it work with variable sheet heights. Any suggestions?

(By the way: No need to worry about compatibility with older browsers like IE<9)

Answer №1

If I grasp your requirements correctly, the functionality you are looking for can be achieved with the assistance of the jQuery UI accordion.

You may establish it using the following HTML structure:

<div id="sheets">
  <h3><a href="#sheet1">Sheet 1</a></h3>
      <div>
       Content for sheet 1 goes here
      </div>
      <h3><a href="#sheet2">Sheet 2</a></h3>
      <div>
       Content for sheet 2 goes here
      </div>
      <h3><a href="#sheet3">Sheet 3</a></h3>
      <div>
       Content for sheet 3 goes here
      </div>
</div>

For the jQuery part, utilize the following script:

$("#sheets").accordion({
  autoHeight: false
});

This will dynamically adjust the size of the content sections based on their natural height.

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

Reordering Divs in Bootstrap 3 Specifically for Small Screens

Just getting started with my first responsive design project, and I'm wondering if it's possible to achieve something like this using Bootstrap 3. The goal is to switch from the current layout: https://i.stack.imgur.com/lABXp.jpg To https://i. ...

Encountering difficulties linking to a stylesheet or a script in an HTML file delivered by Express server

Currently, I'm facing the challenge of breaking down my Express app code into multiple files. Unfortunately, I am unable to utilize <link href> or <script src> for linking stylesheets or scripts. Below is the relevant snippet from my inde ...

Issue with preventdefault() function in Internet Explorer 8

I've encountered a problem while working on a page that heavily utilizes ajax. Everything seems to be functioning well across different browsers, except for one final step that is broken in IE8 and below. You can view the issue on this demo page: To ...

Access-Control-Allow-Origin issue with ExpressJS Post Method

I've been delving into numerous articles on CORS, yet I'm still struggling to resolve the infamous 'No 'Access-Control-Allow-Origin'' issue. The challenge lies in making a post request to my node/expressjs server using jQuery ...

In order to showcase an image ahead of another (stay tuned),

Help! I'm facing a dilemma here. I have an abundance of adorable animal images with unique facial expressions, but there's one problem - the eyes are hidden! I desperately want to showcase those captivating eyes. This is what my code looks like. ...

Combining a Python backend with an HTML/CSS/JS user interface for desktop applications: the perfect synergy?

Is it possible to seamlessly combine Python code with HTML/CSS/JS to develop desktop applications? For instance, I want to create a function in Python that displays "Hello World!" and design a visually appealing user interface using HTML/CSS/JS. How can I ...

Looking to switch up the hide/show toggle animation?

Currently, I have a functioning element with the following code. It involves an object named #obj1 that remains hidden upon page load but becomes visible when #obj2 is clicked. #obj1{ position:fixed; width:100px; bottom:180px; right:10 ...

Fetching JSON data with Ajax is successful, but the information is not being displayed

I am struggling to showcase Json data from a URL in a table using ajax. The aim is for the code to iterate through the data and present it neatly in a table. <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/a ...

Is it recommended to rely on Javascript for altering the content of a div across an entire website?

I am in the process of creating my personal portfolio and have a few inquiries regarding the framework to implement. Currently, I have an index.html page that contains all the information I want displayed when visitors land on the site. Additionally, ther ...

Eliminate the outline of the pager row in an asp.net grid view

Within my grid view, I have applied a bottom border to all cells. However, this border is also appearing on the pager row, which is not desired. To address this issue, I attempted to use jQuery to remove the border, but it seems that my selector is incorre ...

What is causing find_by_css to return nothing when using nth-child?

Currently, I am facing an issue when trying to extract the "href" link from the following HTML code: https://i.stack.imgur.com/Gtzf4.png This is the code that I'm using: from selenium import webdriver from splinter import Browser from bs4 import Be ...

The absence of color attribute in CSS serves as a safeguard against overriding

Issue Update: Upon pushing the application to the development server, ASP includes injected styles that are overriding the necessary custom styles. One specific example is a wrapper div with an 'a' tag that overrides all styled 'a' tags ...

The HTMLEditor from ASP.NET AJAX Control Toolkit is not appearing correctly on the page

My experience with the ASP.NET AJAX Control Toolkit HTMLEditor has been less than satisfactory. The toolbar layout is not being displayed correctly, with what should be a 3-line toolbar appearing stretched out to 9 lines. ...

CSS: Maintain rounded corners on body border even when scrolling

I am attempting to create a body border on my webpage with rounded corners at the top to simulate the MacOS interface in the browser, similar to the image shown here: The issue arises when I scroll, and the top corners vanish: This is the HTML (although ...

What steps can I take to prevent automatic redirection when submitting an input on an AJAX form in PHP?

I have encountered a strange issue with my HTML post loading dynamically inside a modal popup. I noticed that when I submit the form directly in the post, it works fine but doesn't work inside the modal :/ Every time I try to submit the form from the ...

Steps for eliminating an element using jQuery from a variable filled with HTML code

I'm developing a forum where users have the ability to quote other users' comments. When a user clicks on "quote" for a comment, it captures the HTML of that comment and displays it in a box that says Quote: Original post by a member, similar t ...

CSS designs that adapt flawlessly to high-resolution mobile devices with perfect responsiveness

Currently, I am implementing max-width: 768px to modify the appearance of my website. However, with the increasing number of high-resolution devices available in the market such as 4K mobile phones, I am wondering how I can detect them. Should I consider ...

Trigger modal following unsuccessful registration

I have a method in the controller for registering users. [HttpPost] public ActionResult Register(RegisterViewModel register) { if (this.IsCaptchaValid("Captcha is not valid")) { if (ModelState.IsValid) { ...

Tips for modifying the appearance of an anchor <a> element within a table cell with jQuery

One issue I am facing involves changing the style of a specific element within a table cell using jQuery. The change needs to be based on the value in another cell. Below is the table structure: <table id="table"> ...

"Instead of sending JSON to the AJAX jQuery request, the PHP `json_encode` function is used

Creating a simple contact form as a WordPress plugin, I have developed a form as a popup within the same page: <form method="post" id="w_form" enctype="multipart/form-data"> <label for="first_name" class="text-secondary">First Name</la ...