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

Removing values in javascript for checkboxes that are not selected

Here is the JavaScript Code : var clinicalStat; var id; var val; var clinicalVals; $(":checkbox").click(function() { //alert(" you checked"); if ($(this).is(':checked')) { var checked1 = $(this).val(); //Inital value of check ...

Position footer at the bottom of the webpage and adjust the height to be filled with main content using Bootstrap 4

I am currently in the process of designing a bootstrap layout that includes a header navbar along with a footer. My goal is to ensure that the footer is always at the bottom of the page, even if there is limited content. Here's what I have implemente ...

What is the best way to position elements with CSS?

I need help aligning the arrows and images on the same line. Can anyone guide me on how to do this? (I'm using html5boilerplate). Desired Layout: Current Layout: Existing Code: HTML: <div id="linkbar"> <a><img src="./img/ar ...

Obtain the value using jQuery from an AJAX request and display it

When I write the code below, the alert output is null: var availableSlots = ""; $.get( '', { availableSlots: userName }, function(a) { availableSlots = a; }); alert(availableSlots); Putting the alert inside the get function works fine, but ...

Accessing CustomState in FluentValidation from the client side

I am trying to combine bootstraps .alert alert-warning classes with FluentValidation in order to display or hide warning messages. My idea was to add a custom state to the rule and then pass it to the client side for displaying/hiding the alert message, bu ...

Disabling the @import cache feature in LessCSS Assetic

I'm facing a minor issue that is robbing me of precious time. Currently, I am using the assetic plugin with the lesscss filter in my symfony2.1 project. The problem lies in Assetic not detecting changes in imported files when using the @import functi ...

In a remarkable design with an array of buttons and an individual div assigned to each, a fascinating functionality unfolds. Whenever a

https://i.stack.imgur.com/emhsT.png When I click on the first "Respond" button, I want the adjacent text box to disappear. Currently, if I click on the first "Respond" button, both text boxes will disappear instead of just the first one. $('.comment ...

Exploring the capabilities of the jQuery `val()` function alongside the dynamic framework

Whenever I have a JavaScript variable that contains HTML printed from a table on my server, I encounter issues when using it in a jQuery function like val(). The problem arises every time someone enters content with special characters like " or '. Thi ...

One way to trigger the same modal to open when clicking on a shared class using jQuery

I need some assistance with opening a model upon clicking the same link. Currently, when I click on the link, only the backdrop briefly appears and then the page reloads. Any help would be greatly appreciated. Thank you in advance. Below is the code snipp ...

What causes the height and width properties in a div to remain unchanged even after using the zoom/scale CSS?

I'm trying to center a CSS spinner on the page, but I am struggling with making it happen. Even when scaled down by 50%, the height and width remain at 200px. <div class="center" style=""> <div class="uil-default-css" style="width: 200px ...

Obtaining values from a jQuery slider for the price range

<meta charset="utf-8"> <title>jQuery UI Slider - Range slider</title> <link rel="stylesheet" href="jquery.ui.all.css"> <script src="jquery-1.7.1.js"></script> <script src="jquery.ui.widget.js">< ...

Is there a way to modify the color scheme of my webpage while utilizing Bootstrap?

As I delve into programming with Bootstrap, I encountered an issue while attempting to change the background color of my body. Even though I used the following CSS code: body { background-color: #eba; width: 100%; height: 100%; } The color change ...

Positioning pictures in front of a backdrop

I'm facing an issue with a section that slides into view with a blue background. I want to add a picture in the upper left corner, but it's barely visible and the blue background disappears. Here's a snippet of the HTML code: <header id ...

Strategies for determining the direction of a slide event within a Bootstrap carousel

I am attempting to identify the direction of the slide in a Bootstrap 4 carousel when the user initiates the slide event. Is there a method to achieve this? $('#myCarousel').on('slide.bs.carousel', function () { //Determine wheth ...

jQuery mobile enhancing user experience with dynamic background images

I am having trouble setting different background images for each page in jQuery Mobile. <div data-role="page" id="pageone">... </div> <div data-role="page" id="pagetwo">... </div> Since each page has a unique ID, I tried ...

Ajax is able to send a string representation of a list rather than just the raw list itself

Utilizing jQuery to collect all the data entered on the webpage, then utilizing ajax to transmit this information to my django view. Here is the code responsible for that: var button = $("#serialise"); var JSON_content = $('#JSON_Contents') $( ...

Is it possible to adjust the button's position based on the location of the cursor?

I am just starting to learn JavaScript, so I am not yet familiar with all the commands involved. I have a code that includes a button which scrolls back to the top of the page, but I was wondering if there is a way to change the position of that button bas ...

The jSON data is being retrieved on the second request instead of the first request

I am facing an issue while processing a query and loading jSON data upon success. Strangely, the jSON data is only displayed correctly starting from the second attempt onwards. Yes, that's right. When I click the submit button for the first time, the ...

In MUI v5 React, the scroll bar vanishes from view when the drawer is open

Currently, I am working on developing a responsive drawer in React using mui v5. In the set-up, the minimum width of the drawer is defined as 600px when it expands to full width. However, an issue arises when the screen exceeds 600px - at this point, the d ...

Converting bullet point list to checkboxes once requirements have been satisfied

I am working on developing a password validator with specific regex conditions in Material UI that transitions from bullet points to checkboxes when the criteria are satisfied. Initially, I attempted to use the npm library NiceInputPassword, but it did no ...