What could be causing my CSS transitions to fail when using jQuery to add classes?

I'm currently working on a website and I'm facing an issue with the transition not functioning as expected. The problem persists even when the 7.css stylesheet is removed and interestingly, the transition works fine when using window:hover.

My attempt to add a class through jQuery should trigger a CSS transition on the window class. However, this doesn't seem to be happening as intended. The class gets added but the transition does not occur.

HTML:

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <link rel="stylesheet" href="https://unpkg.com/7.css">
  </head>
  <body>
    <div class="vertical"></div>
    <div id=info1>
    <div class="window active glass center400" style="max-width:400px;">
      <div class="title-bar">
        <div class="title-bar-text">Info</div>
        <div class="title-bar-controls">
          <button aria-label="Minimize" disabled></button>
          <button aria-label="Maximize" disabled></button>
          <button aria-label="Close" class=closewindow data-parentid=info1 onclick=closeinfo()></button>
        </div>
      </div>
      <div class="window-body has-space">
        <h4>donkeys are pretty cool</h4><br><br>
        i love donkeys.
      </div>
    </div>
    </div>
  </body>
</html>

CSS:

    body {
      margin: 0;
      padding: 0;
      background: url(img0.jpg) center center fixed;
      overflow: hidden;
    }
      .window {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        transform: perspective(0), rotateZ(0);
        opacity: 1;
        -webkit-transition: 200ms ease all, 300ms ease opacity;
        -moz-transition: 200ms ease all, 300ms ease opacity;
        -ms-transition: 200ms ease all, 300ms ease opacity;
        transition: 200ms ease all, 300ms ease opacity;
      }
      .window-body {
        -webkit-user-select: default;
        -ms-user-select: default;
        user-select: default;
      }
      div.vertical {
        display: none;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        z-index: 1000 !important;
        background: red;
      }
      
      @media only screen and (max-aspect-ratio: 6/5) {
        div.vertical {
          display: block;
        }
      }
      h4 {
        padding: 0;
        margin: 0;
      }
      .center400 {
        left: calc(50vw - 200px);
        top: 35vh;
      }
      [role=button],button{
          transition: 100ms;
      }
      .close {
        transform-style: preserve-3d;
        transform: perspective(1500px) rotateX(10deg) translateY(-10px);
        opacity: 0;
      }

jQuery:

     function closeinfo() {
        $("#info1").addClass("close");
      }
      $(".window").draggable({
        handle: ".title-bar"
      });

fiddle: fiddle

Answer №1

After some trial and error, I finally solved the issue by removing the wrapper div and adding #info to the window 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

Tips for effectively utilizing Mongoose models within Next.js

Currently, I am in the process of developing a Next.js application using TypeScript and MongoDB/Mongoose. Lately, I encountered an issue related to Mongoose models where they were attempting to overwrite the Model every time it was utilized. Here is the c ...

Switching the file format from HTML to .ASP resulted in the loss of the website's design elements and images

After initially creating an HTML file, I decided to rename it with a .asp extension for uploading online. To do this, I copied the original HTML file and moved it into a folder containing .asp files. However, after replacing the existing file, my website l ...

"Communication breakdown in Vue.js: $emit event not being picked up by corresponding $

Vue.component('rating-edit', { template:` <form> <input v-model="rating.title" type="text"> <textarea v-model="rating.remark">{{rating.remark}}</textarea> <button type="button" @click=" ...

Tips for implementing a custom filter in an AngularJS JavaScript controller

Can anyone help me with creating a custom filter in an AngularJS JavaScript controller? I need to be able to search for items in an array called segments by their SegmentId. The filter should iterate through the segments array and return the segment that ...

Using an HTML5 image icon as an input placeholder

Is there a way to incorporate an image icon into an input placeholder and have it disappear when the user starts typing, across all browsers? In trying to achieve this, I successfully implemented a solution for webkit (Safari+Chrome) using ::-webkit-input ...

What is the process for duplicating a set of elements within an svg file and displaying the duplicate at a specific location?

SVG <svg width="200" height="200"> <g id="group"> <rect x="10" y="10" width="50" height="20" fill="teal"></rect> <circle cx=" ...

What is the best way to create a dynamic hyperlink that leads to a detailed information page based on the specific link clicked?

I'm currently working on a web page that displays a list of users, and I want each user's name to be clickable, leading to a page with specific details about that user. I'm new to this field, so I'm unsure where to start. My idea is to ...

Using discord.js does not allow line breaks in embed descriptions

const chatRoom = replyOptions.getRoom("room"); const header = replyOptions.getHeader("header"); const content = replyOptions.getContent("text"); const chatEmbed = new MessageEmbed() .setColor('DARK_VIVID_PURPLE') ...

Error message: "Unable to find a windows instance" encountered while conducting tests on Paho MQTT Client using mocha and typescript

After spending countless days searching online, I have yet to find any resources on testing the Paho MQTT Client. My approach so far has been somewhat naive, as shown below: import { suite, test, slow, timeout, skip, only } from 'mocha-typescript&apo ...

Use React to insert a leading zero next to a number in the input field if the number is greater than 10

I have scoured the web and consulted resources like this one but haven't found a solution that addresses my specific issue with adding padding to input numbers. My goal is to automatically add a leading zero whenever the number inside an input field i ...

Indexes in JqGrid data array

My challenge is loading a data array into JQGrid, where the indexes in the array start from around 40000 and represent IDs of elements. Sample array structure: array[45698] = array('id' => 45698, 'data', ..); Is there a way to con ...

Accessing Google Feed API to retrieve media thumbnails

I am currently utilizing the Google Feed API to extract a thumbnail from an RSS feed ("media:thumbnail") The media:thumbnail element in the RSS feed is structured as follows: <media:thumbnail url="http://anyurl.com/thumbnailname.jpg" width="150" heigh ...

Tips for reducing the amount of white space on a card featuring a pie chart in a mobile layout

Is there a way to adjust the size of the pie chart or reduce the white space at the bottom? In the mobile view after inspecting with Chrome dev tools, it seems like the chart is not displaying as desired. Here is the screenshot <div ...

Can an image map area be identified using radial coordinates?

While I have experience with online Imagemap Generators for rectangular or circular areas in HTML pages, things get a bit tricky when dealing with pie-shaped sections. When trying to make each pie slice a separate area, the image map code generated by thes ...

Adjust the canvas size to fit its parent element ion-grid

I am currently working on an Ionic 3 component that displays a grid of images connected by a canvas overlay. I have utilized Ionic's ion-grid, but I am facing an issue with resizing the canvas. The problem is that I cannot determine the correct dimens ...

Using vue-resource to intercept an ajax error and catching the "Uncaught (in promise)" exception

I am utilizing vue-resource to retrieve data from the server. In order to access the correct data, a user must possess a JWT token. If the token is invalid or has expired, a status code of 401 will be returned. Similarly, if a user attempts to reach a forb ...

NodeJs and Mysql query execution experiencing significant delays

NodeJs + Mysql query delays and execution timing issue https://github.com/mysqljs/mysql Hello everyone, I'm facing a problem with mysql js. Whenever I use .query(), the callback is taking too long to execute and returning empty results. However, if I ...

Accessing a value in JSON (beginner level)

Hello everyone! I have come across a URL: . My goal now is to extract the value (Price) of a specified key (name). I am aware that there have been similar inquiries in the past, but unfortunately, I haven't been able to make it work as JSON is relat ...

Creating optimized CSS builds for Next.js production

In dev mode, I have separate Custom CSS files for different layouts which work fine. However, when I publish my app in production mode, Nextjs combines all the CSS files together causing issues with my layouts. ...

Incorporating CSS styles into a dynamic JavaScript computation

I'm attempting to apply inline CSS to a JS calculation (e.g. 3*2*1) in order to make it appear red. I have experimented with using a span tag, but it only displays the calculation and not the result. I also tried utilizing an internal style sheet. Ho ...