trouble with overlapping mdl-sheet instances

Hey there! I have a quick question - Is it possible to have multiple mdl-sheets on one page that all share the same form?

I tried implementing this but ended up with them overlapping each other instead of displaying next to each other from left to right.

Check out my code here. The issue seems to be in the CSS.

CSS:

/* This CSS was downloaded from https://www.codeseek.co/ */
body {
  background: #ECEFF1;
}

.mdl-layout__content {
  padding: 24px 12px;
}
.mdl-layout__content h1 {
  font-size: 30px;
  margin: 0 0 .3em;
}

.mdl-sheet__container {
  right: 32px;
  bottom: 32px;
  -webkit-transform: rotate(0deg);
          transform: rotate(0deg);
}

.mdl-sheet {
  position: relative;
  background: #FF5722;
  float:left;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  -webkit-transition: all 180ms;
  transition: all 180ms;
}
.mdl-sheet .mdl-sheet__content {
  display: none;
}

.mdl-sheet__icon {
  color: #fff;
  position: static;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-12px, -12px);
          transform: translate(-12px, -12px);
  font-size: 24px;
  width: 24px;
  height: 24px;
  line-height: 24px;
}

.mdl-sheet--opened {
  background: #fff;
  color: #263238;
  border-radius: 2px;
  width: 240px;
  height: auto;
  min-height: 150px;
  max-height: 80vh;
  overflow-y: auto;
}
.mdl-sheet--opened .mdl-sheet__icon {
  display: none;
}
.mdl-sheet--opened .mdl-sheet__content {
  display: block;
}

Answer №1

There was an issue with overlapping sheets due to inserting another mdl-sheet inside a previous one. To resolve this, I applied the CSS property display:inline-block to ensure they are displayed next to each other from left to right.

var $sheet = $('.mdl-sheet');

if ($sheet.length > 0) {
  $('html').on('click', function() {
    $sheet.removeClass('mdl-sheet--opened')
  });

  $sheet.on('click', function(event) {
    event.stopPropagation();

    $sheet.addClass('mdl-sheet--opened');
  });
}
/* Styles modified for better readability and organization */

body {
  background: #ECEFF1;
}

.mdl-layout__content {
  padding: 24px 12px;
}
 /* Additional styles omitted for brevity */
.mdl-sheet--opened .mdl-sheet__content {
  display: block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<div class="mdl-sheet__container">
  <div class="mdl-sheet mdl-shadow--2dp">
    <i class="material-icons mdl-sheet__icon">add</i>
    <div class="mdl-sheet__content">
      <div class="mdl-list">
        <!-- List items content removed for brevity -->
      </div>
    </div>
  </div>
  <div class="mdl-sheet mdl-shadow--2dp">
    <i class="material-icons mdl-sheet__icon">add</i>
    <div class="mdl-sheet__content">
      <div class="mdl-list">
        <!-- List items content removed for brevity -->
      </div>
    </div>
  </div>
</div>

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

Achieve maximum height with background images

Having trouble with responsiveness on my box containing a background image. I am aiming for the box to adjust its height based on the background image, as I have set the background-size attribute to auto. html: <div class="index_boxs" id="discover_win ...

Use jQuery to smoothly scroll to the top of a DIV that is currently being opened

One issue I am facing is with an accordion that opens and closes upon clicking. The problem lies in the fact that when I click on it, I want the page to scroll to the top of the div. However, my current code is not quite achieving this - it scrolls to wher ...

Can someone explain why my table in Laravel is only showing the third set of data and not the others?

I'm facing an issue with displaying all of the data in my table named taglineImageCarousel. The problem lies in the slide_ID column, where it is being populated with data from slide-01, slide-02, and slide-03. Below is the code snippet: taglineImage ...

Adjusting the size of images in real time

Currently, I am in the process of creating a Fluid grid style website and I am looking to decrease the size of all images by 75% when the screen is below 1280px, 50% at 800px, and so forth. Is there a way to achieve this using the IMG tag? My attempt so ...

Provide the email address to use on the forum

Is there a way to code an email address in HTML that will be invisible and undetectable by forums? Thank you in advance. I'm looking for a more advanced solution like this one! <h>mariaburkke76</h><h><h><h><h>< ...

I am looking to initiate the animation by triggering the keyframe upon clicking a button

Is there a way to create an animation triggered by a button click instead of loading the page? Each table data cell has its own class with a unique keyframe defining the style changes over time. @-webkit-keyframes fadeIn { from { opacity:0; ...

The data input from the HTML is not being correctly transferred to the modal

I am trying to transfer the reservation id from an HTML element to a modal window. When I click "cancel" next to a reservation, a modal should appear showing the reservation id. However, the modal pops up without displaying the reservation id. Can anyone h ...

Tips for resolving the Range issue with jQuery-UI slider and activating a function when changes are made

I created a simple form that calculates an estimated price based on quantity and one of three options. Then, I attempted to integrate a jQuery-UI slider into the form. However, I encountered an issue where the slider was displaying values outside of the sp ...

Navigate through the seamless elements with scroll snapping

I need to find a way to make horizontal scrolling on my really wide graph snap to specific points along the x-axis. I initially tried using scroll-snap-points-x, but unfortunately it doesn't seem to be supported. My attempt to add invisible elements ...

Discovering the largest value with arrays in javascript

My code is functioning as expected for single-digit numbers but encounters issues with two or three-digit numbers. I want to stick to this approach without utilizing the math max function. The primary issue lies in only considering the first digit of a tw ...

Align the responsive image in the center of a container

I am facing a challenge in centering an image wrapped by an anchor tag inside a div. I have tried using display flexbox and justify-content:center for the image, which works to some extent. However, the height of the image remains constant while the width ...

Tips for improving the readability of HTML within a JavaScript file

This is the HTML I have been given <div data-role="collapsible"> <div class="prd-items-detials"> <ul> <li class="head"> <form> <label class="testtt" for="checkbo ...

Encountering the error "unrecognized pseudo-class :lang" following the Angular update

Recently, I updated my node version and encountered a new error: custom-file-input:lang(en)~.custom-file-label -> unmatched pseudo-class :lang I'm not sure what's causing this issue. Can someone help me troubleshoot this error? My current n ...

What is the best way to split <hr> tags into different sections?

I'm striving to create a design similar to this - https://i.sstatic.net/hcaST.png Initially, I attempted to use a hr tag and modify it for my purposes. However, my efforts have not yielded the desired outcome. Any assistance in understanding this co ...

Can you include an optional selector in SASS?

Here is an interesting concept: adding a CSS-selector optionally to the existing selector stack within a mixin. This is what I envision: @mixin myMixin(mobileSelector:true) { @if(mobileSelector) { .foo .mobile:before, } .classXY .subclass:before ...

jQuery: Retrieve data from a table

I am currently working on using an HTML table as a look-up table. Normally, I would handle this server-side, but in this particular case, the client will be inputting the table. When filling out a form, they provide two values from columns A and B, which t ...

Customizing Material UI: Adjusting the visibility of slider thumb upon user interaction and value changes in the slider

In my application, I have implemented a Material UI Slider and I am looking to keep the thumb invisible until the user interacts with it. Once the user changes the slider value, I want the thumb to remain visible at that specific value. By using the CSS pr ...

Creating a stunning HTML 5 panorama with GigaPixel resolution

Interested in creating a gigapixel panorama using HTML 5 and Javascript. I found inspiration from this example - Seeking advice on where to begin or any useful APIs to explore. Appreciate the help! ...

Why isn't this ajax script able to successfully transmit the data?

I'm having some trouble sending a JavaScript variable to a PHP file in order to create a query. Here's the script I've been using, but unfortunately it doesn't seem to be working. Any assistance would be greatly appreciated. <select ...

Can anyone tell me the location of the modalColor with the background set to 'greenYellow' in the popup window?

Take a look at the sample in jQuery.bPopup.js called Example 2b I am trying to design a popup window with customized text and background style, using the Example 2b, custom settings: Simple jQuery popup with custom settings (Jamaican popup, relax man) $ ...