Concealing a block from top to bottom

I currently have a filter that is hidden when clicked, with a transition effect that moves it from the bottom to the top. I have recorded my screen to demonstrate this behavior: . However, I now need the filter to hide from top to bottom instead, essentially reversing the animation so that it ends up showing the filter button.

.filter-block {
  background-color: #fff;
  padding: 20px 0 1px;
  position: relative;
  transition: max-height 0.5s ease, padding 0.5s ease 0.3s;

  > .container {
    transition: opacity 0.5s ease-in 0.2s;
    opacity: 1;
  }
&--hide {
    max-height: 0;
    padding: 0;
    overflow: hidden;
    > .container {
      transition: opacity 0.5s ease-in-out;
      opacity: 0;
    }
  }
}

<div className={cn('filter-block', {
   'filter-block--hide ': !showMainFilter
 })}> code inside </div>

Answer №1

$('.shide').click(function(){
    $(this).next().slideToggle();
});
.slidediv {
    height:300px;
    background-color: red;
    color: #fff;
    padding:20px;
    display:none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="shide">Show/hide</div>
<div class="slidediv">
Hi Man. </div>

Check out: http://jsfiddle.net/uniak/249ybqgv/

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

What is the most efficient way to iterate through an array to push properties into an object nested within another array?

I have been working on a small Angular application that functions as a scheduler, allowing users to input a Name, Start and End dates, and toggle a boolean checkbox through a form. One challenge I am facing is trying to assign the names entered by each use ...

When a user clicks on an element, use jQuery to show a specific

I am looking to extract the Admission ID field within a separate function that triggers when a user clicks on a button. $(document).ready(function () { $.each(data.student, function (i, item){ trHTML += '<tr>'+ ...

Disable the full screen camera mode on iOS browsers while live streaming camera video

I recently completed a tutorial on capturing video streams from the front or rear camera of an iPhone using JavaScript. The tutorial can be found at this link. While testing the functionality on my desktop browser, everything worked perfectly. However, wh ...

Anti-virus programs are preventing long-standing AJAX connections

Hey there, I have come across something quite strange while developing a web application that relies on long-held HTTP connections using COMET to stream data between the server and the application. The issue I've encountered is that some anti-virus p ...

Steps for properly inserting a hyperlink:

I'm in need of assistance. I have a grid containing several images that I want to make clickable by adding anchor tags, but when I do this, the images seem to disappear completely. I suspect there's an issue with them being inside the container d ...

Ways to safeguard NextJS Route Handlers from unauthorized access beyond my website

While using the NextJS 14 App Router, I noticed that my Route Handlers for APIs were accessible to my friend via Postman from his PC. This was unexpected as I assumed they were protected by default due to the same-origin policy headers in NextJS. However, ...

I have developed a custom jQuery carousel that includes functionality to start and stop the carousel based on specific conditions

I have set up a jQuery carousel that moves to the left when a checkbox is checked, but I need it to stop moving when the checkbox is unchecked. Can someone help me achieve this? $("#checkBox").click(function(){ if($(this).prop("checked") == true){ ...

Finding the median value within a collection of objects

I am working with an array of objects containing book details: const booksData = [{"author":"john","readingTime":12123}, {"author":"romero","readingTime":908}, ...

Can a jQuery/JavaScript script be run standalone?

I've got a bunch of HTML pages saved on my computer and I'm looking to create a JavaScript script that can extract specific text or elements from those pages. I found some jQuery code snippets on Stack Overflow that do what I need, but I'm n ...

What are the steps to decode a JSON response using jQuery?

Working on a fun little web app for my significant other and me to keep track of movies we want to watch together. I'm exploring using TheMovieDatabase.org's API (which only supports JSON) to simplify the process of adding movies to our list. The ...

Adding TypeScript types to an array within a function parameter: A step-by-step guide

Having some trouble defining the array type: The code below is functioning perfectly: const messageCustomStyles: Array<keyof IAlertMessage> = [ 'font', 'margin', 'padding' ]; r ...

a guide on monitoring the status of a stripe transaction through a straightforward form and javascript

Currently, I am in the process of setting up Stripe checkout for my website. I have successfully implemented the payment form, but now I need to figure out how to redirect the user to another page after a successful payment. Below is the JavaScript code th ...

What could be causing the alignment issue with cells in Bootstrap?

I'm currently facing an issue with Bootstrap where two columns that are supposed to appear side-by-side on medium resolution end up displaying one below the other. You can view a screenshot of the problem here, and the code can be found at this link. ...

retrieving an element from a collection of objects

For a project utilizing the openweather api, I encountered fluctuating data based on the time of day it is viewed. My goal is to loop through the first 8 objects to identify a dt_txt value of 12:00:00. Once found, I intend to store this result in a variabl ...

Transforming Bootstrap using Typescript styled components

I have been working on customizing the Navbar in my React app using Typescript's styled components. However, I am facing difficulties in restyling the default styles from Bootstrap that I have copied. Here is an example of the React Bootstrap Navbar c ...

Is there a method available for us to successfully deliver an email to the user who has been registered?

I am currently working on the registration page for my React app. One of the requirements is to send a confirmation email to the user's email address once they have registered. The user's account will only be confirmed once they click on the veri ...

Using Material-UI: A guide on how to dynamically display the label value of a select element

Currently, I am utilizing the multiple select component from MUI. When the user selects an option, it displays the value of the select tag to the user. However, my goal is to have it display the label of the select tag instead. You can find a demo of this ...

I am in need of assistance with styling Material UI elements. Can anyone lend a hand with

https://i.stack.imgur.com/37daN.png The image above shows my current layout. I would like the icon to appear on the right-hand side instead. I am currently using material-ui design in my project. Is there a way to achieve this positioning? import React ...

When using the command npx create-react-app myapp, it produces a FETCH_ERROR

npm ERROR! FETCH_ERROR occurred npm ERROR! FETCH_ERROR code returned npm ERROR! Received invalid JSON response from http://registry.npmjs.org/@typescript-eslint%2fparser due to Unexpected numeric value in JSON at character position 80754 No solutions hav ...

Having trouble retrieving response content in Mithril

I've been experimenting with making a request to a NodeJS API using the Mithril framework in my client application. I attempted to fetch data by following their example code: var Model = { getAll: function() { return m.request({method: "G ...